There is a related question GET pull request merge commit sha from pull request number using github api, yet there is no answer.
According to GitHub API, once Pull Request was merged, it triggers the pull_request
event with action: closed
. The event is also available from Events API. However, there are only merged
(which is true
if the pull request was merged) and deprecated merge_commit_sha
(SHA of temporary merge commit, not the actual commit by which pull request was merged) fields.
There is also API for dealing with pull requests; yet, according to the documentation, it also will only return whether pull request was merged, and what is the temporary commit SHA (in a deprecated field).
Pull request is clearly associated with the merge commit somehow, as commit SHA is shown on pull request page:
Is there some way to get programmatically SHA of the commit by which pull request was merged to the base, knowing the pull request ID?
All pull requests are also issues. So you can fetch the Issue Events for any Pull Request. With that, there will be a commit_id
. If that attribute is present with a merged
attribute then that should be the SHA of the merge commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With