How to get the last commit of PR merged w/ merge commit

Related: How to get latest commit from a PR merge?

In my situation I’d like the main / master branch to be able to retrieve the Last commit (before the merge commit) after merging to master

So assuming this:

  • Merged #31 from branch-name to master
  • Last commit in the PR
  • Normal commit
  • First commit

I would like to retrieve the Last commit in the PR when the push.branches: [master] is running the merged PR.

Ideally, it’d be able handle things gracefully when the PR is merged without a merge commit (via squash or rebase)

If you have the pull number, it’s pretty simple. Consider vcs-python/vcspull.

If you know you’re interested in vcs-python/vcspull#326, you can still access the head of the PR after it’s merged:
https://github.com/vcs-python/vcspull/compare/master...refs/pull/326/head

refs/pull/XX/head.

Be careful though, a tip of a PR can itself be a merge.