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:
commit
4c237708d8
2 changed files with 31 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue