Incorrect PR merge commit returned when PR merged via git


#1

Hi there,

I noticed that the API returns the wrong PR mergeCommit when the PR was merged via git (instead of using the GitHub interface). Instead of getting the actually merge commit I get the last commit made to the PR.

This is also the case with the REST API.

Thanks
Nick


#2

Hi @nomeyer, thanks for reporting this.

Is this something that you’re observing consistently across all of your repositories? If so, would you mind listing the reproduction steps?

If it’s not something you’re seeing consistently, it would be a great help to have a specific case (with SHAs) to investigate.

Lastly, if this is happening in a private repository, then please contact support@github.com so you’re not sharing private information here.


#3

Hi @kytrinyx, thanks for your quick response.

Unfortunately this is the only PR we’ve merged via git so I can’t tell whether it’s consistent behaviour or not. It should be pretty easy to replicate on your side though to see if you observe the same behaviour consistently.

It’s happening in a private repo so I’ll send some details over by email.

Thanks


#4

Perfect, thanks!


#5

To summarise the resolution (via email) for whoever ends up here after facing the same issue: when the branch of a PR is merged locally via git and then pushed, it’s difficult (but not impossible) to figure out exactly which commit merged the PR. GitHub currently resorts to treating the last commit to the PR as the merge commit. This is both the case on the UI and with the APIs.

Apparently it’s unlikely that this will be fixed soon because it’s too computationally expensive to find the right merge commit in this setting.