Merge pull request #5779 from cli/merge-queue-api-fix

pr merge: fix merge queue API access for PAT consumers
This commit is contained in:
Mislav Marohnić 2022-06-09 14:51:56 +02:00 committed by GitHub
commit 4c237708d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View file

@ -72,9 +72,12 @@ func (d *detector) IssueFeatures() (IssueFeatures, error) {
}
func (d *detector) PullRequestFeatures() (PullRequestFeatures, error) {
if !ghinstance.IsEnterprise(d.host) {
return allPullRequestFeatures, nil
}
// TODO: reinstate the short-circuit once the APIs are fully available on github.com
// https://github.com/cli/cli/issues/5778
//
// if !ghinstance.IsEnterprise(d.host) {
// return allPullRequestFeatures, nil
// }
features := PullRequestFeatures{
ReviewDecision: true,

View file

@ -20,6 +20,14 @@ func TestPullRequestFeatures(t *testing.T) {
{
name: "github.com",
hostname: "github.com",
queryResponse: map[string]string{
`query PullRequest_fields\b`: heredoc.Doc(`
{ "data": { "PullRequest": { "fields": [
{"name": "isInMergeQueue"},
{"name": "isMergeQueueEnabled"}
] } } }
`),
},
wantFeatures: PullRequestFeatures{
ReviewDecision: true,
StatusCheckRollup: true,
@ -28,6 +36,23 @@ func TestPullRequestFeatures(t *testing.T) {
},
wantErr: false,
},
{
name: "github.com with no merge queue",
hostname: "github.com",
queryResponse: map[string]string{
`query PullRequest_fields\b`: heredoc.Doc(`
{ "data": { "PullRequest": { "fields": [
] } } }
`),
},
wantFeatures: PullRequestFeatures{
ReviewDecision: true,
StatusCheckRollup: true,
BranchProtectionRule: true,
MergeQueue: false,
},
wantErr: false,
},
{
name: "GHE",
hostname: "git.my.org",