pr merge: fix merge queue API access for PAT consumers
The github.com API right now doesn't seem to make merge queue APIs available to people who use PAT to authenticate gh requests. This switches the conditional request strategy to also do feature-detection for dotcom (instead of just for Enterprise).
This commit is contained in:
parent
743a747804
commit
9351f272dc
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