Get all PRs in a range of commits, possible?


#1

Hi,

I’m trying to figure out if it’s possible to get a list of PR (fields) from a range of commits. It looks as if it’d be possible with the baseRefName and headRefName filter attributes, but I couldn’t find a more detailed description of what they are. So, I’ve tried:

{
  repository(owner: "org", name: "repo") {
    pullRequests(
      first: 1
      headRefName: "SHA-1",
      baseRefName: "SHA-1"	
    ) {
      edges {
        node {
          number
        }
      }
    }
  }
}

But it returns an empty array:

{
  "data": {
    "repository": {
      "pullRequests": {
        "edges": []
      }
    }
  }
}

Am I misunderstanding what those filters are for? Any ways to do that currently in single query?

Thanks in advance!


#2

Base and head are not a range of commits.

The pull request “base” is the branch that the pull request is made into. In most cases, this is the project’s master branch. The pull request “head” is the branch that the pull request is made from. In most cases, this is a feature branch or the master branch of someone’s fork.


Find Pull Request Containing Specific Commit Hash
#3

Similar yet slightly different request – I’d like to send a list commitA, commitB, commitC and get a response of the sort commitA: PR#2, commitB:null, commitC: PR#10.

From what I can tell this is not currently possible, but submitting this request so you’re aware that someone out there has this need :slight_smile:

Let me know if you’d like more details about the use case, happy to talk through it.