GitHub - Find the pull request associated with a commit

Viewed 16455

I'm trying to find a past pull request to see which comments / actions were made on a particular issue.

I know the file and the change, so I can get to the commit that introduced it by looking at the blame view. However I can't find a way to look at the pull request that pushed that commit to the branch for the first time.

Is there a way to do this? Or do I have to go on a trip down memory lane and manually browse through past pull requests?

2 Answers

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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Related