Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the pull request that introduced a commit

In github, when I click on a commit, I can see the pull request that introduced it.

commit with link to PR that introduced it

You can see this commit was introduced by PR 15.

How can I get the associated pull request for a particular commit from the Github API?

like image 535
HParker Avatar asked Nov 23 '25 22:11

HParker


1 Answers

the #15 indicates the issue/PR number. If you have a commit sha it is possible to find the associated PR# using the GitHub search API (v3).

For example, suppose you have a commit sha - 7dd1bcf5f2f5eeed34cc2ec63053098fba302b6c. To find the PR# from this sha, your query using the GitHub APi can look something like this- https://api.github.com/search/issues?q=sha:7dd1bcf5f2f5eeed34cc2ec63053098fba302b6c. From JSON response, the field 'number' represents the PR# (in this case 16).

Ref. Search Issues

like image 175
Poonacha Avatar answered Nov 25 '25 16:11

Poonacha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!