Skip to content

Commit

Permalink
Use gh.Exec instead of os.Exec
Browse files Browse the repository at this point in the history
  • Loading branch information
ataberkcanitez committed Dec 6, 2023
1 parent 8ee9861 commit 4d71d35
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"bufio"
"fmt"
"os/exec"
"github.com/cli/go-gh/v2"
"strings"
)

Expand All @@ -17,12 +17,11 @@ type PullRequest struct {
}

func (gs *GitHubService) GetOpenPullRequests() ([]PullRequest, error) {
cmd := exec.Command("gh", "search", "prs", "--review-requested", "@me", "--state", "open")
output, err := cmd.Output()
prs, _, err := gh.Exec("search", "prs", "--review-requested", "@me", "--state", "open")
if err != nil {
return nil, fmt.Errorf("error running git status: %v", err)
return nil, fmt.Errorf("failed to execute gh command: %w", err)
}
return parsePullRequests(string(output)), nil
return parsePullRequests(prs.String()), nil
}

func parsePullRequests(prLine string) []PullRequest {
Expand Down

0 comments on commit 4d71d35

Please sign in to comment.