#5052 closed enhancement (fixed)
GitHub integration: Show whether a linked PR is approved
Reported by: | noisysocks | Owned by: | dd32 |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | Trac | Keywords: | |
Cc: |
Description
It would be helpful in Trac to see whether the linked PR is 'Approved' or has 'Changes requested' in the 'Pull Requests' section at the top of a ticket.
Potentially this could be integrated into the 'All checks pass' status, e.g:
- ✅ All checks pass, approved
- ❌ All checks pass, changes requested
- ✅ All checks pass
Change History (8)
#2
follow-up:
↓ 3
@
5 years ago
It looks like you have to access a separate endpoint:
https://api.github.com/repos/WordPress/gutenberg/pulls/$pr_number/reviews
This returns a JSON list of reviews for the given pull request, and:
- If the list is empty, there are no reviews.
- If there are no items in the list with
"state"
equal to"APPROVED"
, there are changes requested. - If there is ≥ 1 items in the list with
"state"
equal to"APPROVED"
, the PR is approved.
#3
in reply to:
↑ 2
@
5 years ago
Replying to noisysocks:
It looks like you have to access a separate endpoint:
https://api.github.com/repos/WordPress/gutenberg/pulls/$pr_number/reviews
Unfortunately this is going to require using a higher-access access token, so pending this task via #4903 which is kind of strange given the endpoint is accessible unauthenticated (Just at a low rate limit)
❌ Switch to using a Github App OAuth Token from dd32's personal Github token get_authorization_token() (or change it to select a random users token..)
class stdClass#4 (2) { public $message => string(38) "Resource not accessible by integration" public $documentation_url => string(77) "https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request" }
Do you have an example of how this is shown in the Github API? or a PR which fits the Approved/Changes-Requested state?