I am developing an automation tool that deals with GitHub pull requests and need to find the full list of GitHub pull request review statuses but couldn't get that either on its own API documentation page or generally on the web.
Those I've already found include APPROVED, CHANGES_REQUESTED, PENDING and DISMISSED. Appreciate if someone can provide me the full list.
This refers to GitHub Enterprise version of 2.12.
Check the list of available statuses in GraphQL API docs. There is the link. I'm pretty sure that other APIs (for instance, REST) also support and provide the same list.
There is a snippet from the documentation:
PullRequestReviewState
The possible states of a pull request review. Values
APPROVED
A review allowing the pull request to merge.
CHANGES_REQUESTED
A review blocking the pull request from merging.
COMMENTED
An informational review.
DISMISSED
A review that has been dismissed.
PENDING
A review that has not yet been submitted.
Related
I need a way to get when a reviewer for a GitHub PR was requested using their API, but looking through the documentation there seems to be no way to do it. Is there any way that I can get the information I need?
If you want to be notified when a pull request review was requested, you can set up a webhook for the pull_request event. Then, you can listen for the review_requested and review_request_removed actions and do whatever you'd like in response.
Note that with GitHub webhooks, you will get all of the messages for a particular event, and you're responsible for filtering out the ones you want. GitHub doesn't provide filtering capabilities.
It could be useful for review purposes, for example, if one wants to review pull requests written by someone from her team.
According to GitHub's documentation1, it's possible to filter PRs by the team that was requested for review, but not if a member actually created it.
1 https://help.github.com/en/github/managing-your-work-on-github/filtering-issues-and-pull-requests
Just for completeness (after all this time): this is not possible: the UI does not allow that search. It's also not available as filter in the PR REST API's.
You might be able to do this with the GraphQL API, but I have not tried that.
I'm building a service which scans for open pull requests with a specified tag, and merges them automatically if they have been reviewed appropriately.
In some cases, PR's will include changes to files owned by a team in the CODEOWNERS file. To my knowledge, GitHub API has no support for Code Owners.
Is this true? Is there any way to verify whether a PR has been reviewed by a Code Owner? I cannot find any discerning info in the API responses which identify whether or not a review is by a Code Owner or just another user.
Thanks!
Github provides an API for pending reviews, without differentiating whether that reviewer is a CODEOWNER or not.
From what I understand, this service needs to check whether there are pending reviews on the PR, so in this case it doesn't matter if its a codeowner or not, because your call to github API reviews will return that there are indeed pending reviews.
Another tool you can use is codeowners-api which can help you understand map whether the reviewers on a PR are indeed CODEOWNERS
Disclaimer - I wrote the library
Running on GitHub Enterprise I have a small Jenkins job that looks for pull-request comments and triggers a script depending on the message.
Now I only want to trigger the script if review is already done from GitHub point of view, like all CODE_OWNERS and no additional person requested changes. I don't want to implement that logic myself. GitHub has different section for reviews and status checks. I only want review state, since I am going to set the status myself.
But I was not able to the correct value from the API endpoint. Neither from pull-request itself, nor from pulls/id/reviews.
Closest that i found was "mergeable_state", but this unfortunately takes the status check into consideration.
Is there another place to look for?
I don't think you can fetch the global review status. I think that the best you can do is to check that there are no review requests and fetch all reviews to check if there are no requested changes.
Finally we decided to make a Probot app in Github which was able to get all the required information.
I'd like to see a summary of the pull requests where I contributed review comments.
Currently I review the list of all pull requests with a URL such as
https://github.com/user/project/pulls?q=is%3Apr
Because multiple people review, I can't rely on setting myself as the Assignee of the pull request.
Adding my username to the search terms doesn't work.
Try the following URL:
https://github.com/search?q=commenter%3Adefunkt+repo%3Aajaxorg%2Face&type=pr
This will find all pull requests (type=pr) on GitHub from the #ajaxorg/ace repository where user defunkt made a comment.
The GitHub documentation can tell you how to do more if you need it.