Merge pull request #3688 from cli/pr-merge-fix

Fix `pr merge` with GHE < 3.0
This commit is contained in:
Mislav Marohnić 2021-05-21 19:30:32 +02:00 committed by GitHub
commit 09a92c6e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 47 deletions

View file

@ -208,6 +208,8 @@ func PullRequestGraphQL(fields []string) string {
q = append(q, prFiles)
case "commits":
q = append(q, prCommits)
case "lastCommit": // pseudo-field
q = append(q, `commits(last:1){nodes{commit{oid}}}`)
case "commitsCount": // pseudo-field
q = append(q, `commits{totalCount}`)
case "statusCheckRollup":

View file

@ -156,7 +156,7 @@ func mergeRun(opts *MergeOptions) error {
findOptions := shared.FindOptions{
Selector: opts.SelectorArg,
Fields: []string{"id", "number", "state", "title", "commits", "mergeable", "headRepositoryOwner", "headRefName"},
Fields: []string{"id", "number", "state", "title", "lastCommit", "mergeable", "headRepositoryOwner", "headRefName"},
}
pr, baseRepo, err := opts.Finder.Find(findOptions)
if err != nil {

View file

@ -464,11 +464,8 @@ func Test_nonDivergingPullRequest(t *testing.T) {
}
stubCommit(pr, "COMMITSHA1")
shared.RunCommandFinder(
"",
pr,
baseRepo("OWNER", "REPO", "master"),
)
prFinder := shared.RunCommandFinder("", pr, baseRepo("OWNER", "REPO", "master"))
prFinder.ExpectFields([]string{"id", "number", "state", "title", "lastCommit", "mergeable", "headRepositoryOwner", "headRefName"})
http.Register(
httpmock.GraphQL(`mutation PullRequestMerge\b`),
@ -505,11 +502,8 @@ func Test_divergingPullRequestWarning(t *testing.T) {
}
stubCommit(pr, "COMMITSHA1")
shared.RunCommandFinder(
"",
pr,
baseRepo("OWNER", "REPO", "master"),
)
prFinder := shared.RunCommandFinder("", pr, baseRepo("OWNER", "REPO", "master"))
prFinder.ExpectFields([]string{"id", "number", "state", "title", "lastCommit", "mergeable", "headRepositoryOwner", "headRefName"})
http.Register(
httpmock.GraphQL(`mutation PullRequestMerge\b`),

View file

@ -12,24 +12,7 @@
"state": "CLOSED",
"url": "https://github.com/cli/cli/pull/8",
"headRefName": "blueberries",
"reviewDecision": "CHANGES_REQUESTED",
"commits": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"state": "SUCCESS"
}
]
}
}
}
}
]
}
"reviewDecision": "CHANGES_REQUESTED"
}
}
]

View file

@ -12,24 +12,7 @@
"state": "MERGED",
"url": "https://github.com/cli/cli/pull/8",
"headRefName": "blueberries",
"reviewDecision": "CHANGES_REQUESTED",
"commits": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"state": "SUCCESS"
}
]
}
}
}
}
]
}
"reviewDecision": "CHANGES_REQUESTED"
}
}
]