Skip to content

Commit 50d6008

Browse files
authored
Merge pull request cli#13327 from cli/wm/fix-pr-view-number-only-optimization
fix(pr): remove numberFieldOnly optimization that skips API validation
2 parents 611b01f + 8ff70e6 commit 50d6008

2 files changed

Lines changed: 0 additions & 25 deletions

File tree

pkg/cmd/pr/shared/finder.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
207207

208208
fields := set.NewStringSet()
209209
fields.AddValues(opts.Fields)
210-
numberFieldOnly := fields.Len() == 1 && fields.Contains("number")
211210
fields.AddValues([]string{"id", "number"}) // for additional preload queries below
212211

213212
if fields.Contains("isInMergeQueue") || fields.Contains("isMergeQueueEnabled") {
@@ -248,11 +247,6 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
248247

249248
var pr *api.PullRequest
250249
if f.prNumber > 0 {
251-
// If we have a PR number, let's look it up
252-
if numberFieldOnly {
253-
// avoid hitting the API if we already have all the information
254-
return &api.PullRequest{Number: f.prNumber}, f.baseRefRepo, nil
255-
}
256250
pr, err = findByNumber(httpClient, f.baseRefRepo, f.prNumber, fields.ToSlice())
257251
if err != nil {
258252
return pr, f.baseRefRepo, err

pkg/cmd/pr/shared/finder_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -326,25 +326,6 @@ func TestFind(t *testing.T) {
326326
},
327327
wantErr: true,
328328
},
329-
{
330-
name: "number only",
331-
args: args{
332-
selector: "13",
333-
fields: []string{"number"},
334-
baseRepoFn: stubBaseRepoFn(ghrepo.New("ORIGINOWNER", "REPO"), nil),
335-
branchFn: func() (string, error) {
336-
return "blueberries", nil
337-
},
338-
gitConfigClient: stubGitConfigClient{
339-
readBranchConfigFn: stubBranchConfig(git.BranchConfig{}, nil),
340-
pushDefaultFn: stubPushDefault(git.PushDefaultSimple, nil),
341-
remotePushDefaultFn: stubRemotePushDefault("", nil),
342-
},
343-
},
344-
httpStub: nil,
345-
wantPR: 13,
346-
wantRepo: "https://github.com/ORIGINOWNER/REPO",
347-
},
348329
{
349330
name: "pr number zero",
350331
args: args{

0 commit comments

Comments
 (0)