Have PullRequestForBranch accept "owner:branch" value for forks

When on a `patch-1` branch locally, `gh pr view` would happily open the
first open PR it finds with "patch-1" as its head, even those coming
from forks.
This commit is contained in:
Mislav Marohnić 2019-11-18 20:52:34 +01:00
parent c7a38b6331
commit 508f6787f0
5 changed files with 77 additions and 81 deletions

View file

@ -243,13 +243,11 @@ func prView(cmd *cobra.Command, args []string) error {
return err
}
prs, err := api.PullRequestsForBranch(apiClient, baseRepo, currentBranch)
pr, err := api.PullRequestForBranch(apiClient, baseRepo, currentBranch)
if err != nil {
return err
} else if len(prs) < 1 {
return fmt.Errorf("the '%s' branch has no open pull requests", currentBranch)
}
openURL = prs[0].URL
openURL = pr.URL
}
fmt.Printf("Opening %s in your browser.\n", openURL)