Skip to content

Output merge commit hash for Merged PR's in gh pr view  #2306

Description

Describe the feature or problem you’d like to solve

I'm looking to automate a task where I document specific merged PR's in another system. I can obtain the author, PR number, and PR title by parsing the current output of gh pr view 123. I can derive the PR link from the PR number (I already know the repo.)

The information I'd like to have available is the commit hash representing the merge commit created when the PR was squashed and merged.

Proposed solution

For a PR with status Merged, append the merge commit hash in the status string of gh pr view:

$ gh repo clone gobridge/gopher
$ gh pr view 31
post alternate platform song links
Merged in 22090be • therealplato wants to merge 6 commits into master from songlink



  I want to hear posts in #howplaying without creating a spotify account or  <snip>

Additional context

I only use squash and merge. I'm not sure if other options would break this approach.

Activity

  1. ghost added
    enhancementa request to improve CLI
    on Oct 27, 2020
  2. added
    coreThis issue is not accepting PRs from outside contributors
    on Oct 29, 2020
  3. dwgillies-bluescape commented on Apr 13, 2022

    @dwgillies-bluescape

    Is it possible to get the merged PR hash for a merged PR in the UI ?? I have not been able to find this anywhere. I am reduced to searching the repo list-of-commits every time I have to do a cherrypick to another branch, and this is a big productivity-killer for cherry-picks.

  4. samcoe commented on Apr 14, 2022

    @samcoe
    Contributor

    @dwgillies-bluescape You can use gh pr view --json mergeCommit to retrieve the merge commit SHA.

  5. dwgillies-bluescape commented on Apr 14, 2022

    @dwgillies-bluescape

    Yes, I understood that your gh command works, but only :

    • before i switch to another branch to perform the cherry pick
    • after i have remembered to git pull to get the merge commit back from github

    It's not a very useful feature. stamping the commit itself on the website itself would be far more useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions