Merge pull request #13327 from cli/wm/fix-pr-view-number-only-optimization
fix(pr): remove numberFieldOnly optimization that skips API validation
This commit is contained in:
commit
50d6008f4d
2 changed files with 0 additions and 25 deletions
|
|
@ -207,7 +207,6 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
|
|||
|
||||
fields := set.NewStringSet()
|
||||
fields.AddValues(opts.Fields)
|
||||
numberFieldOnly := fields.Len() == 1 && fields.Contains("number")
|
||||
fields.AddValues([]string{"id", "number"}) // for additional preload queries below
|
||||
|
||||
if fields.Contains("isInMergeQueue") || fields.Contains("isMergeQueueEnabled") {
|
||||
|
|
@ -248,11 +247,6 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
|
|||
|
||||
var pr *api.PullRequest
|
||||
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
|
||||
}
|
||||
pr, err = findByNumber(httpClient, f.baseRefRepo, f.prNumber, fields.ToSlice())
|
||||
if err != nil {
|
||||
return pr, f.baseRefRepo, err
|
||||
|
|
|
|||
|
|
@ -326,25 +326,6 @@ func TestFind(t *testing.T) {
|
|||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "number only",
|
||||
args: args{
|
||||
selector: "13",
|
||||
fields: []string{"number"},
|
||||
baseRepoFn: stubBaseRepoFn(ghrepo.New("ORIGINOWNER", "REPO"), nil),
|
||||
branchFn: func() (string, error) {
|
||||
return "blueberries", nil
|
||||
},
|
||||
gitConfigClient: stubGitConfigClient{
|
||||
readBranchConfigFn: stubBranchConfig(git.BranchConfig{}, nil),
|
||||
pushDefaultFn: stubPushDefault(git.PushDefaultSimple, nil),
|
||||
remotePushDefaultFn: stubRemotePushDefault("", nil),
|
||||
},
|
||||
},
|
||||
httpStub: nil,
|
||||
wantPR: 13,
|
||||
wantRepo: "https://github.com/ORIGINOWNER/REPO",
|
||||
},
|
||||
{
|
||||
name: "pr number zero",
|
||||
args: args{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue