For a PR with number 1 GitHub automatically creates a ref
refs/pulls/1/merge. The latter contains the result of the merge and is especially useful for e.g. CI (because what you want to test is actually the result of the merge).
After merging a PR, the
refs/pulls/<number>/merge is no longer available (I suppose because the PR is no longer mergeable). Currently I want to run a test on a version that was merged a while ago. Is there an easy way to access the result of the merged PR, given just the PR number?
Best How To :
The following should do the trick even though you should be aware that there are possibly multiple "children" of a commit (someone else could base work on the PR and merge it into master again later):
$ git rev-list -n1 upstream/pull/<number>..upstream/master
This works by getting the first commit walking from
upstream/master. Luckily github leaves
upstream/pull/<number> just on the last commit of the PR.
Here's an example of https://github.com/RDFLib/rdflib:
It's current history looks like this:
* 371263f - (upstream/pull/486) Removed debugging print statement
* fe3fa52 - (upstream/master, upstream/HEAD) Merge pull request #482
| * 354c352 - (upstream/pull/482) fix broken example
* f81e0b2 - Merge pull request #480
Here some test output:
$ git rev-list -n1 upstream/pull/482..upstream/master
$ git rev-list -n1 upstream/pull/486..upstream/master