GitHub - Find the pull request associated with a commit
GitHub has recently added an easier way to do this to their GraphQL API: https://developer.github.com/v4/changelog/2019-03-08-schema-changes/.
Here's an example query which demonstrates how to fetch associated pull requests of the five latest commits on the master branch:
{
repository(name: "react", owner: "facebook") {
ref(qualifiedName: "master") {
target {
... on Commit {
id
history(first: 5) {
nodes {
id
associatedPullRequests(first: 10) {
edges {
node {
title
}
}
}
}
}
}
}
}
}
}
You can filter your pull requests based on the commit SHA - see here
If you know the specific SHA hash of a commit, you can use it to search for pull requests that contain that SHA. Note that the SHA syntax must be at least seven characters.
For example:
e1109ab Matches pull requests with a commit SHA that starts with
e1109ab
.
0eff326d6213c is:merged Matches merged pull requests with a commit SHA that starts with
0eff326d6213c
.