Is there any api to get all issues associated with a given list of commit #24541
-
Given a list of commits, I want to get all the issues linked to those commits. Is there any rest or graphql api available today to fetch above information? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
There isn’t an API for this because it is done by pattern recognition in the commit comment. When a commit is pushed that references an issue or PR, an event is added to the issue to refer back to the commit but no such metadata is created for the commit. |
Beta Was this translation helpful? Give feedback.
-
https://help.github.com/articles/searching-issues-and-pull-requests/#search-by-commit-sha The above api says "If you know the specific SHA hash of a commit, you can use it to search for pull requests that contain that SHA." Isn’t there any way to get issues using search api? I think pull request are treated as issues only by GitHub. |
Beta Was this translation helpful? Give feedback.
-
There are ways to get a list of issues via the search API but not via a commit SHA, no, for the reasons I stated before. |
Beta Was this translation helpful? Give feedback.
-
(Posting this here in case someone else finds it useful as I was having a hard time figuring out how to get Issues linked to a Pull Request) There’s no direct way of getting a list of Issues linked to a Pull Request. But each Pull Request includes a timeline of events and one of those events is when an Issue gets linked. Using the timeline of events I was able to write a GitHub APIv4 API request and some javascript to get the Issues linked to a PR: First, here’s the GraphQL query:
If you run this in the GitHub GraphQL Explorer (https://developer.github.com/v4/explorer/), you’ll see all the events that an Issue was connected and disconnected to a Pull Request. Using that query, I pass the response to this code that I wrote for a nodejs app that then determines which Issue is still linked to the Pull Request
The logic here is as follows:
It’s not a super elegant solution, but it solves what I need, which was to find those Linked issues. Hopefully this helps someone else out |
Beta Was this translation helpful? Give feedback.
-
In our organization, we merge everything to "develop". Once a week or bi-weekly we merge everything from "develop" to "master". We want to have a list of all the issues associated with the PR in the PR description based on the commits, which are linked to the issues (with #issue-number). Is it possible? Ive tried a lot of things but nothing seemed to work. But im not to experienced with the Github Rest API |
Beta Was this translation helpful? Give feedback.
There isn’t an API for this because it is done by pattern recognition in the commit comment. When a commit is pushed that references an issue or PR, an event is added to the issue to refer back to the commit but no such metadata is created for the commit.