Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeCommit is missing from the PR attribute list #5114

Closed
fruch opened this issue May 9, 2024 · 1 comment
Closed

mergeCommit is missing from the PR attribute list #5114

fruch opened this issue May 9, 2024 · 1 comment

Comments

@fruch
Copy link

fruch commented May 9, 2024

mergeCommit is missing from the PR attribute list

https://docs.mergify.com/configuration/conditions/#attributes-list

in github api it called merge_commit_sha
https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request

in via gh cli:

❯ gh pr view 6968 --json mergeCommit
{
  "mergeCommit": {
    "oid": "35de46e2fe9f2cd5403f88ed9d4cbe3b0303a2cf"
  }
}

it would really be helpful, since that the commit on the target branch of the PR, the commits list available is from the origin branch that is coming from a fork, and even gonna be delete later, so it leaves pointing to dangling commit that are much less helpful

even this isn't enough, since there not way inside the jinja template to execute more api call, to retrieve the rest of the patchset commits

here's a bash script I'm using to retrieve the list of commit of the target branch of a PR (after it was merged):

function get_pr_commits() {
    PR_NUM=$1

    MERGE_COMMIT=$(gh pr view $PR_NUM --json mergeCommit | jq -r '.mergeCommit.oid')
    PR_COMMITS=""

    commit=$MERGE_COMMIT
    while :
    do
        COMMIT_PR=$(gh api /repos/{owner}/{repo}/commits/$commit/pulls | jq -r '.[].number')
        if [[ $COMMIT_PR == $PR_NUM ]]; then
            PR_COMMITS="$PR_COMMITS $commit"
            FOUND_FIRST=yes
        fi

        if [[ $COMMIT_PR != $PR_NUM ]] && [[ ! -z $FOUND_FIRST ]]; then
            break
        fi
        commit=$(gh api /repos/{owner}/{repo}/commits/$commit | jq -r '.parents[0].sha')
    done
    echo $(reverse $PR_COMMITS)
}

a way to get something equivalent would be really helpful

@jd
Copy link
Member

jd commented May 13, 2024

Hi @fruch !
Thanks for reporting this. We'll look into this and try to add this to our the list of PR attribute.

@linear linear bot closed this as completed May 16, 2024
@linear linear bot reopened this May 16, 2024
@linear linear bot closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants