Ivan Guardado
Ivan Guardado

Reputation: 527

How to get pull requests references for an issue

Given a GitHub issue, is there any way to get the pull requests that reference to that issue via API?

That info is showed in the GitHub html page but I can't see nothing in the API documentation.

Is it really possible?

Upvotes: 4

Views: 490

Answers (1)

VonC
VonC

Reputation: 1323953

is there any way to get the pull requests that reference to that issue via API

Not directly.
Even the reverse is not possible, as a pull request has a link 'issue' pointing to... itself.

But as mentioned in the issue API:

In the past, pull requests and issues were more closely aligned than they are now.
As far as the API is concerned, every pull request is an issue, but not every issue is a pull request.

This endpoint may also return pull requests in the response. If an issue is a pull request, the object will include a pull_request key.

So you would need to list the comments of a pull request (using the Issue Comments API since comments on PR are done with it), and parse said comment to find a reference to an issue.

Upvotes: 1

Related Questions