-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-approve when another review is requested #209
Conversation
const commit = pull_request.data.head.sha; | ||
const { owner, repo } = context.repo; | ||
const queryParams = { owner, repo, pull_number: prNumber }; | ||
const [pullRequest, reviews, requestedReviewers] = await Promise.all([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hmarr, while doing the fixes, I realized we can get requested_reviewers
from pull_request
, I was about to PR this, so no additional rest calls should be necessary, if my understanding is correct with how Github API works
for (const review of reviews.data) {
if (
review.user?.login == login &&
review.commit_id == commit &&
review.state == "APPROVED" &&
pull_request.data
.requested_reviewers?.filter(
reviewer => reviewer.login == login
).length == 0
) {
core.info(
`Current user already approved pull request #${prNumber}, nothing to do`
);
return;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh great point! Please do change that and submit the PR. I'd definitely rather avoid the extra request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh great point! Please do change that and submit the PR. I'd definitely rather avoid the extra request.
The code is vastly different now, so I recommend for you to do the change 😁 on how you like it, but just suggesting that we can get the field without the additional rest call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'll close this out in favour of your pull request. Thanks for contributing!
When a review has already been left for the current commit, but the review is dismissed and re-requested, we should leave another approving review.
This also switches uses
Promise.all
to fetch the PR, review, and review requests concurrently.Closes #206.