-
Notifications
You must be signed in to change notification settings - Fork 67
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
User Response to Pull Request Review #121
Conversation
Hi @jameesjohn. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
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 @jameesjohn, took a pass, PTAL. Thanks!
constants.js
Outdated
@@ -8,7 +8,9 @@ const editEvent = 'edited'; | |||
const issuesLabelEvent = 'issues_labeled'; | |||
const issuesAssignedEvent = 'issues_assigned'; | |||
const pushEvent = 'push'; | |||
const pullRequestReviewEvent = 'pr-review'; |
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.
pr_review
just to be consistent.
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.
Done.
lib/checkPullRequestReview.js
Outdated
@@ -287,6 +288,75 @@ const handlePullRequestReview = async (context) => { | |||
} | |||
}; | |||
|
|||
/** | |||
* This function checks when a pull request gets commented on by the PR author. |
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.
when a pull request gets commented on by the PR author --> when PR author comments on the pull 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.
Done.
lib/checkPullRequestReview.js
Outdated
@@ -287,6 +288,75 @@ const handlePullRequestReview = async (context) => { | |||
} | |||
}; | |||
|
|||
/** | |||
* This function checks when a pull request gets commented on by the PR author. | |||
* If pr author comments on the PR asking reviewers please to take a look (ptal), |
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.
please to take a look (ptal) --> to please take a look (PTAL)
We will need to update wiki as well to have this info and how oppiabot responds.
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.
Yes. This is contained in the doc, and I believe that will be shared with the dev community.
lib/checkPullRequestReview.js
Outdated
/** | ||
* This function checks when a pull request gets commented on by the PR author. | ||
* If pr author comments on the PR asking reviewers please to take a look (ptal), | ||
* We check if the reviewers have been assigned and if not, assign them. |
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.
We check if the reviewers have been assigned and if not, assign them --> the function checks if the reviewers have been assigned and if not, assigns them
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.
Done.
lib/checkPullRequestReview.js
Outdated
* @type {import('probot').Octokit.IssuesGetResponse} | ||
*/ | ||
const pullRequest = context.payload.issue; | ||
const isPullRequest = 'pull_request' in pullRequest; |
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.
pull_request -> constant
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.
Done.
|
||
// Pause for 3 minutes in case author wants to perform | ||
// the required actions. | ||
await utilityModule.sleep(THREE_MINUTES); |
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.
One suggestion regarding the 3 minutes thing - we should also add this to the case when we ask author to assign the reviewers if they are the codeowners - I have noticed that the comment pops really quick even when I am about to assign the reviewer. This one to be specific: https://github.com/oppia/oppiabot/blob/master/lib/checkPullRequestLabels.js#L117. You can update it here or in a separate PR as well.
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.
Do you think the 3 minutes wait time is needed here?
The response here should be immediate I believe.
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.
See this for example, I already assigned a reviewer but oppiabot still leaves a comment. So, we can keep the wait time shorter but we should definitely have it. WDYT?
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.
Okay.
I'll add it in a separate PR where I'll also be adding features for the new default changelog label.
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.
Sounds good, thanks!
issue_number: updatedPullRequest.number, | ||
assignees: unassignedUsers, | ||
}) | ||
); |
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.
Add comment too - Hi @ .. assigning you since author requested for a review. Thanks!
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.
I'm not sure we should still comment here since we are reacting to a comment already made by the pr author.
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.
Hmm, makes sense. But let us unassign the author as well.
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.
Done.
lib/checkPullRequestReview.js
Outdated
@@ -287,6 +288,76 @@ const handlePullRequestReview = async (context) => { | |||
} | |||
}; | |||
|
|||
/** | |||
* This function checks when PR author comments on the pull 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.
checks when -> handles the case when a
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.
Done.
lib/checkPullRequestReview.js
Outdated
@@ -287,6 +288,76 @@ const handlePullRequestReview = async (context) => { | |||
} | |||
}; | |||
|
|||
/** | |||
* This function checks when PR author comments on the pull request. | |||
* If pr author comments on the PR asking reviewers please to take a look (PTAL), |
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.
please to take a look (PTAL) -> to please take a look (PTAL)
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.
Done.
lib/checkPullRequestReview.js
Outdated
/** | ||
* This function checks when PR author comments on the pull request. | ||
* If pr author comments on the PR asking reviewers please to take a look (PTAL), | ||
* The function checks if the reviewers have been assigned and if not, assigns them. |
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.
Line too long - break.
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.
Done.
lib/checkPullRequestReview.js
Outdated
|
||
const usersInComment = utilityModule.getUsernamesFromText(comment.body); | ||
// Check if assignment was carried out by author. | ||
const assignees = updatedPullRequest.assignees.map((assignee) => assignee.login); |
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.
Break if line too long.
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.
Done.
lib/checkPullRequestReview.js
Outdated
const unassignedUsers = usersInComment.filter((user) => | ||
!assignees.includes(user) | ||
); | ||
console.log({ unassignedUsers }); |
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.
We don't need this.
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.
Removed.
issue_number: updatedPullRequest.number, | ||
assignees: unassignedUsers, | ||
}) | ||
); |
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.
Hmm, makes sense. But let us unassign the author as well.
spec/checkPullRequestReviewSpec.js
Outdated
}); | ||
}); | ||
|
||
it('should assign remaining reviewer', () => { |
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.
reviewer -> reviewers
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.
Done.
spec/checkPullRequestReviewSpec.js
Outdated
}); | ||
|
||
describe( | ||
'when the comment is from an issue and not a pull 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.
from -> on
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.
Done.
|
||
// Pause for 3 minutes in case author wants to perform | ||
// the required actions. | ||
await utilityModule.sleep(THREE_MINUTES); |
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.
See this for example, I already assigned a reviewer but oppiabot still leaves a comment. So, we can keep the wait time shorter but we should definitely have it. WDYT?
(assignee) => assignee.login === updatedPullRequest.user.login | ||
); | ||
if (authorIsAssigned) { | ||
context.github.issues.removeAssignees( |
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.
Add a comment too - we have unassigned you since a review was requested - please make sure all comments are addressed.
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.
Comment should be something like unassigning @author since a re-review was requested - please make sure all comments are addressed.
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.
Yes, sg.
spec/checkPullRequestReviewSpec.js
Outdated
}); | ||
|
||
describe( | ||
'when author asks reviewer to ptal and does not assign them and author is assigned', () => { |
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.
Break line - please check the complete file.
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.
Done.
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.
Just a few more nits, PTAL. Thanks @jameesjohn!
|
||
// Pause for 3 minutes in case author wants to perform | ||
// the required actions. | ||
await utilityModule.sleep(THREE_MINUTES); |
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.
Sounds good, thanks!
(assignee) => assignee.login === updatedPullRequest.user.login | ||
); | ||
if (authorIsAssigned) { | ||
context.github.issues.removeAssignees( |
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.
Yes, sg.
lib/checkPullRequestReview.js
Outdated
context.repo({ | ||
issue_number: updatedPullRequest.number, | ||
body: | ||
'Unassigning @author since a re-review was requested ' + |
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.
This should be @{updatedPullRequest.user.login}.
`Unassigning @{author} since a re-review was requested. @{author} Please make sure you have addressed all the review comments. Thanks!'
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.
Done.
Thanks
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.
LGTM, Thanks @jameesjohn!
Explanation
This PR adds checks for user responding to user reviews.
This feature has been tested at jameesjohn/oppia#39.
Checklist
This PR is stacked on #116 and new changes are from 9e51c98