-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fixing review state to APPROVED whe 'LGTM' in COMMENTED review #72
Conversation
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
==========================================
+ Coverage 98.09% 98.13% +0.03%
==========================================
Files 13 13
Lines 473 482 +9
==========================================
+ Hits 464 473 +9
Misses 9 9
Continue to review full report at Codecov.
|
@Tiriel Great Work! can you add tests in |
Oh yeah sorry, that's indeed a good idea. I'm on it! |
Original tests were in fact all that was needed. I just had to add a test-case in fixtures for my first draft to make some tests fail. (pr_data tests in fact). Corrected work, now tests still pass with proper test case, and command still responds properly. |
lib/reviews.js
Outdated
* @returns {boolean} | ||
*/ | ||
hasLGTM(object, prop) { | ||
return LGTM_RE.test(object[prop]); |
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.
So this is too loose. It would pass for I'm revoking my LGTM
.
IMHO this should be object[prop].toLowerCase() === 'lgtm'
.
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.
@refack This is already the case for normal comments, I think we should log an info here, like what we do for those, to remind the landers to double-check. The actual context would be too hard to parse without some kind of natural language processing..
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.
Good idea!
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.
OK maybe not log an info here, but make a new type of REVIEW_SOURCES
, maybe FROM_REVIEW_COMMENT
, and warn them in checkReviews
like what we do for FROM_COMMENT
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.
@refack re: I'm revoking my LGTM.
they would've put a red cross there I think? (Although if people could click the wrong button for approvals then they might click the same one for objections..
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 thinking of something I saw last week - nodejs/node#16612 (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.
That case was not a "Request Changes" , just "Don't count me as approver", same as dismissed 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.
Another idea: if we are uncertain about a LGTM, we can log it as ?Reviewed-By: xxx
, and then core-validate-commit should complain about it (it doesn't at the moment, we can update that. For now we can just warn about them ourselves).
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.
On a second thought, I am finding the object[prop].toLowerCase() === 'lgtm'
approach better (although we can just do that by changing LGTM_RE
to /^lgtm$/i
and trim the comments before testing them), it's just simpler that way. I think people who don't give LGTM either this way or with a green review would not mind not being listed in the review-by list. Also it saves you the trouble of listing them back manually if they are already in the metadata.
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.
Most bits LGTM but I think we should log something about the source, like what we do for LGTM in normal comments (hey look at me using LGTM in an CHANGES_REQUESTED XD)
And I'm dismissing my review, so we'll have good data
BTW: people can also dismiss other's reviews, so need to keep track of the author attribution |
@refack Yes, we probably need to dig a bit more into the state machine later as well.. |
By the way, I see that the info telling one PR was approved in comments or commented review is on |
Okay, I've read all the comments, bit confusing xD I think I'll go for both things you suggested if possible @joyeecheung , new source and @joyeecheung @refack Otherwise, what about changing the RegEx to this: |
I know I'm going to be a minority on this but I would scrape the whole LGTM checking (including the existing). Everyone uses the green button. If they're not using and they say 'LGTM' or something that extent, it usually means they scanned it but don't have complete confidence to give it firm approval. I don't think the few times we'll find a legitimate approval that wasn't logged as such will be more frequent than the comments with LGTM where it's a part of a broader statement that is not necessarily an approval. |
For example, what does this count as? (This is from a recent PR I landed.)
I don't think the author would expect to be listed in Or the more common:
|
That's a good point, but actually that's why I would put the notice in warning. In a way, just to say "Some people seem to approve, but be careful". And that's also why I'd say we only register "LGTM" when it's the only thing in the comment (my RegEx proposal) |
Or....maybe we should skip those people in the actual metadata, just log them as "potential reviewers"? |
@joyeecheung I think that's my favourite suggestion so far. |
Fat fingered the close button. Sorry. |
Maybe then keeping the line "XXX reviewed in comment" while removing the review from review count? |
@Tiriel Yes that's what I had in mind. |
@Tiriel Or maybe..
(we can even make this interactive and let the user decide!...although for the moment I think this PR is good with just removing them in the metadata) |
I can do like you said in your last comment, but I feel that would need a more important rework of the workflow that would justify another PR |
bdce824
to
6004aed
Compare
Actually this way other tests fail. Going to rework already :) |
6004aed
to
6779760
Compare
@Tiriel Let's go with regexp then. Also we might want to trim the text before testing them as well. |
6ab5a4e
to
0f48d22
Compare
Done! |
lib/reviews.js
Outdated
case COMMENTED: | ||
map.set( | ||
login, | ||
new Review(r.state, r.publishedAt, r.bodyText, FROM_REVIEW_COMMENT) |
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 suggest we just pass APPROVED
as the state here, like what we do for approval in normal comments. This way we don't need to call isApprovedInComment
in getReviewers
. We still keep the info about its source in review.source
.
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 thanks, that's what I had done in the first place, forgot to reinstate it when reverting
test/fixtures/reviews_approved.json
Outdated
"bodyText": "LGTM", | ||
"state": "COMMENTED", | ||
"author": { | ||
"login": "Baz" |
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.
Can you make a new case for this? This and the case above are overlapping each other so one of them would not be visible in the tests. To do this we need to add another collaborator in collaborators.json
and the readme in the fixtures 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.
Sure thing!
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 are in fact numerous tests using each files. I also had to add an entry in reviewers_approved.json and modify accordingly other tests. Push coming
Also with this we can probably drop the check for |
0f48d22
to
b9b6608
Compare
There, this should do it. I added the |
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.
Very close!
lib/args.js
Outdated
@@ -37,6 +37,12 @@ function buildYargs(args = null) { | |||
describe: 'File to write the metadata in', | |||
type: 'string' | |||
}) | |||
.option('comments', { |
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'd rather let this be --check-comments
with no aliases, in case we need the c
later. This does not seem to be very in demand.
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.
Your desires are my commands!
test/unit/pr_checker.test.js
Outdated
@@ -80,12 +80,13 @@ describe('PRChecker', () => { | |||
|
|||
const expectedLogs = { | |||
warn: [ | |||
['Quux User(Quux)) approved in via LGTM in comments'], |
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 is a redundant )
here..
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.
Actually this redundant parens is in every test and is in fact in the base template :D
I'll remove it everywhere.
Fixed! |
@Tiriel can you add this option in readme. |
Very good idea! Incoming! |
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.
Very minor nits. I think we are good to merge it.
lib/args.js
Outdated
@@ -37,6 +37,11 @@ function buildYargs(args = null) { | |||
describe: 'File to write the metadata in', | |||
type: 'string' | |||
}) | |||
.option('check-comments', { | |||
demandOption: false, | |||
describe: 'Check for\'LGTM\' in comments', |
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.
Same as above^
README.md
Outdated
--owner, -o GitHub owner of the PR repository [string] | ||
--repo, -r GitHub repository of the PR [string] | ||
--file, -f File to write the metadata in [string] | ||
--check-comments Check for'LGTM' in comments [boolean] |
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.
Minor Nit: add a space between for and LGTM 'Check for \'LGTM\' in comments'
Going to merge then, unless someone objects! |
From #67
Tested with nodejs/node#16248 as given in issue #67
Ran lint and tests.
Comments and reviews deeply welcomed!