Guard PR merge queue queries behind feature detection
This commit is contained in:
parent
53a8737c87
commit
4c6358dcbf
3 changed files with 53 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
remotes "github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -139,6 +140,18 @@ func (f *finder) Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, err
|
|||
numberFieldOnly := fields.Len() == 1 && fields.Contains("number")
|
||||
fields.Add("id") // for additional preload queries below
|
||||
|
||||
if fields.Contains("isInMergeQueue") || fields.Contains("isMergeQueueEnabled") {
|
||||
detector := fd.NewDetector(httpClient, f.repo.RepoHost())
|
||||
prFeatures, err := detector.PullRequestFeatures()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if !prFeatures.MergeQueue {
|
||||
fields.Remove("isInMergeQueue")
|
||||
fields.Remove("isMergeQueueEnabled")
|
||||
}
|
||||
}
|
||||
|
||||
var pr *api.PullRequest
|
||||
if f.prNumber > 0 {
|
||||
if numberFieldOnly {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue