Include auto-merge information in gh pr status (#7386)

PRs that have auto-merge enabled are marked with a green "✓ Auto-merge enabled" label.
This commit is contained in:
Martijn Pieters 2023-05-09 21:32:05 +01:00 committed by GitHub
parent e1215e5867
commit 83aaa76141
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 6 deletions

View file

@ -15,7 +15,8 @@
"headRepositoryOwner": {
"login": "OWNER"
},
"isCrossRepository": false
"isCrossRepository": false,
"autoMergeRequest": null
}
}
]
@ -31,7 +32,8 @@
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/8",
"headRefName": "strawberries",
"isDraft": false
"isDraft": false,
"autoMergeRequest": null
}
}
]
@ -46,7 +48,17 @@
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/9",
"headRefName": "apples",
"isDraft": false
"isDraft": false,
"autoMergeRequest": {
"authorEmail": null,
"commitBody": null,
"commitHeadline": null,
"mergeMethod": "SQUASH",
"enabledAt": "2020-08-27T19:00:12Z",
"enabledBy": {
"login": "hubot"
}
}
} }, {
"node": {
"number": 11,
@ -54,7 +66,8 @@
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/1",
"headRefName": "figs",
"isDraft": true
"isDraft": true,
"autoMergeRequest": null
}
}
]

View file

@ -191,7 +191,7 @@ func pullRequestFragment(hostname string, conflictStatus bool) (string, error) {
fields := []string{
"number", "title", "state", "url", "isDraft", "isCrossRepository",
"headRefName", "headRepositoryOwner", "mergeStateStatus",
"statusCheckRollup", "requiresStrictStatusChecks",
"statusCheckRollup", "requiresStrictStatusChecks", "autoMergeRequest",
}
if conflictStatus {

View file

@ -284,6 +284,10 @@ func printPrs(io *iostreams.IOStreams, totalCount int, prs ...api.PullRequest) {
}
}
if pr.AutoMergeRequest != nil {
fmt.Fprintf(w, " %s", cs.Green("✓ Auto-merge enabled"))
}
} else {
fmt.Fprintf(w, " - %s", shared.StateTitleWithColor(cs, pr))
}

View file

@ -91,7 +91,7 @@ func TestPRStatus(t *testing.T) {
expectedPrs := []*regexp.Regexp{
regexp.MustCompile(`#8.*\[strawberries\]`),
regexp.MustCompile(`#9.*\[apples\]`),
regexp.MustCompile(`#9.*\[apples\].*✓ Auto-merge enabled`),
regexp.MustCompile(`#10.*\[blueberries\]`),
regexp.MustCompile(`#11.*\[figs\]`),
}