Skip to content

Include autoMergeRequest information in gh pr (list|view|status) commands #7309

Closed

Description

@mjpieters

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
fi

which 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 enabled

Proposed solution

  • Add autoMergeRequest to 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 AutoMergeEnabled to the PR search qualifiers

  • Add autoMergeRequest to 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.

Implementation tasklist

Activity

  1. changed the title [-]Include autoMergeRequest information in gh pr (list|view|status) commands[/-] [+]Include autoMergeRequest information in gh pr (list|view|status) and gh search prs commands[/+] on Apr 12, 2023
  2. changed the title [-]Include autoMergeRequest information in gh pr (list|view|status) and gh search prs commands[/-] [+]Include autoMergeRequest information in gh pr (list|view|status) commands[/+] on Apr 12, 2023
  3. added
    enhancementa request to improve CLI
    and removed on Apr 17, 2023
  4. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on May 9, 2023
  5. mjpieters commented on May 11, 2023

    @mjpieters
    ContributorAuthor

    The gh pr list PR was rejected, as the maintainers feel it's not a good fit to have the tool filter PRs on the client side.

    We can revisit this if the API ever gains support for filtering on auto-merge state.

  6. removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLI

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions