Apply code review changes
This commit is contained in:
parent
afba7b9e8b
commit
692bdaf578
2 changed files with 9 additions and 5 deletions
|
|
@ -212,7 +212,8 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
|
|||
}
|
||||
|
||||
var pr *api.PullRequest
|
||||
if f.prNumber > 0 || f.branchName == "" {
|
||||
if f.prNumber > 0 {
|
||||
// If we have a PR number, let's look it up
|
||||
if numberFieldOnly {
|
||||
// avoid hitting the API if we already have all the information
|
||||
return &api.PullRequest{Number: f.prNumber}, f.baseRefRepo, nil
|
||||
|
|
@ -221,11 +222,16 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
|
|||
if err != nil {
|
||||
return pr, f.baseRefRepo, err
|
||||
}
|
||||
} else {
|
||||
} else if prRefs.BaseRepo() != nil && f.branchName != "" {
|
||||
// No PR number, but we have a base repo and branch name.
|
||||
pr, err = findForRefs(httpClient, prRefs, opts.States, fields.ToSlice())
|
||||
if err != nil {
|
||||
return pr, f.baseRefRepo, err
|
||||
}
|
||||
} else {
|
||||
// If we don't have a PR number or a base repo and branch name,
|
||||
// we can't do anything
|
||||
return nil, f.baseRefRepo, &NotFoundError{fmt.Errorf("no pull requests found")}
|
||||
}
|
||||
|
||||
g, _ := errgroup.WithContext(context.Background())
|
||||
|
|
|
|||
|
|
@ -180,9 +180,7 @@ func TestFind(t *testing.T) {
|
|||
remotePushDefaultFn: stubRemotePushDefault("", nil),
|
||||
},
|
||||
},
|
||||
httpStub: nil,
|
||||
wantPR: 0,
|
||||
wantRepo: "https://github.com/ORIGINOWNER/REPO",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "number with hash argument",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue