-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the feature or problem you’d like to solve
I'd like to have a method of checking the auto-merge status of a PR using gh pr status ..., gh pr view ... and gh pr list ..., at least as an option in the list of fields for --json output.
Right now, I'd have to use the gh api command to get this information:
gh api repos/{owner}/{repo}/pulls -q '
map(select(.auto_merge)) # filter on PRs with auto-merge enabled
...
'and
if [ -z $(gh api repos/{owner}/{repo}/pulls/$PR_NUMBER -q '.auto_merge') ]; then
# auto-merging is not enabled
fiwhich feels more complicated than it needs to be, especially when combined with
other information requests that gh pr status, gh pr list and gh pr view can fill.
Once auto-merge request status information is included in PR data, the information could be included in the output for gh pr view human-readable output:
$ gh pr view $PR_NUMBER
PRTITLE #PRNUM
PRSTATE • AUTHOR wants to merge #COMMITS commits into TARGET from SOURCE • WHEN
+ADDED -REMOVED • CHECKS
Reviewers: REVIEWERS
Labels: LABELS
Auto-merge: enabled, using MERGEMETHOD • WHEN
...and the raw version for the same:
$ gh pr view $PR_NUMBER | cat
title: PRTITLE
state: PRSTATE
automerge: ["disabled" | "enabled (loginname)"]
author: AUTHOR
labels: LABELS
...As filter options for gh pr list:
$ gh pr list --auto-merge enabled # only prs with auto-merge enabled
...
$ gh pr list --auto-merge disabled # only prs with auto-merge disabled
...in gh pr status output:
$ gh pr status
Created by you
#13 Fix tests [branch]
- Checks passing - Review required - Auto-merge enabledProposed solution
- Add
autoMergeRequestto the supported fields for PR queries; the GraphQL query would
be expanded to:
autoMergeRequest {
authorEmail
commitBody
commitHeadline
mergeMethod,
enabledAt,
enabledBy{login,...on User{id,name}}
}
-
Add
AutoMergeEnabledto the PR search qualifiers -
Add
autoMergeRequestto the possible fields for PRs so you can select on
it with--json
Then use this extra information in gh pr list filtering, and in gh pr view and gh pr status outputs.
Additional context
Neither the REST nor the GraphQL pull request search options include an option to filter by auto-merge status, so the filter would have to be implemented locally, filtering API response data.
The REST API path /search/issues (used by gh search prs) doesn't include auto-merge request status information, so this feature can't be extended to that command.