Skip to content
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

Add Reviewers to pr view in CLI #762

Merged
merged 12 commits into from
May 8, 2020
Merged

Conversation

doi-t
Copy link
Contributor

@doi-t doi-t commented Apr 7, 2020

This PR is a part of #663 (pr view).

(This is a nested PR. #748 needs to be merged at first.) Merged.

The query updates for Reviewers is in #748.

The design must be reviewed The design has been reviewed #663 (comment). The author of a PR won't be included in the Reviewers list as GitHub.com does not include it (this is the reference implementation).

When there is a requested reviewer:
Screen Shot 2020-04-08 at 0 00 25

When there are multiple reviews:
Screen Shot 2020-04-07 at 23 59 59

When there is no reviews and requested reviewer (No metadata too):
Screen Shot 2020-04-08 at 0 00 40

Todos

  • Implement a parser for Reviews and ReviewRequests
  • sort reviewer list
  • Write unit tests

@doi-t doi-t force-pushed the reviewers-in-pr-view branch 2 times, most recently from b18b1b8 to 5bc426b Compare April 9, 2020 15:53
@doi-t doi-t force-pushed the reviewers-in-pr-view branch from 5bc426b to 6223a2c Compare April 9, 2020 16:16
@doi-t
Copy link
Contributor Author

doi-t commented Apr 9, 2020

@ampinsk
I've added colors to the reviewer's state following #663 (comment).

This is a random pick example that includes multiple reviewer's states. I put completed reviews before review requests and sort the reviewer's name alphabetically. As far as I can observe, GitHub.com does further sorting (top > Changes requested > Commented > Approved > Requested > bottom & alphabetical sort of reviewer's name???) but I guess this can be a starting point of gh. 🤔
Screen Shot 2020-04-10 at 1 08 33

This is an example of Commened state.
Screen Shot 2020-04-10 at 1 10 33

@mislav @vilmibm
This PR is also ready for code review once #748 gets merged!

@doi-t doi-t marked this pull request as ready for review April 9, 2020 16:24
@ampinsk
Copy link
Contributor

ampinsk commented Apr 9, 2020

@doi-t yes this is totally great for now! I definitely don't think we need to over optimize right now, this is exactly what we need to start :)

@doi-t
Copy link
Contributor Author

doi-t commented Apr 13, 2020

Solved the conflict and made additional refactoring. Now it's ready for code review.

@billygriffin billygriffin requested review from mislav and vilmibm April 13, 2020 14:59
@tierninho
Copy link
Contributor

tierninho commented Apr 13, 2020

Tested this change and it functions well. 👍

I like that that reviewers and the type of review are both in alpha order, however I noticed that there are actually four ways we can organize this info. I am not sure of the importance of this, but wanted to point it out in case we missed it.

  • (Current version) Alpha order by username and then by review-type, like so:
    Screen Shot 2020-04-13 at 11 38 19 AM
  • Chronologically beginning with the first request for a review. E.g., Tom was requested first, Jerry was second. See sidebar in pic below.
  • Chronologically beginning with an actual review. E.g., Jerry beat Tom to reviewing the PR. See timeline in pic below.
  • We set an alternative particular order, tbd.

Screen Shot 2020-04-13 at 11 29 41 AM

@doi-t
Copy link
Contributor Author

doi-t commented Apr 14, 2020

Thank you for the double-check!

  • Chronologically beginning with the first request for a review. E.g., Tom was requested first, Jerry was second. See sidebar in pic below.
  • Chronologically beginning with an actual review. E.g., Jerry beat Tom to reviewing the PR. See timeline in pic below.

Since an actual review can happen without a review request and "reviews" and "review requests" are managed differently by GitHub, I guess we need to combine them if we go with this idea (e.g. the first review (Approved), the second review (Changes requested), the first review request (Requested), the second review request (Requested)). I'm not sure if we can get the timestamp for "review requests". 🤔

@ampinsk
Copy link
Contributor

ampinsk commented Apr 14, 2020

I'm not too worried about the ordering for this first version! I think whatever's simplest is great, and we can always iterate on this detail in the future if we find people are getting confused by this or are needing more nuanced ordering 😄

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me! Thank you for the hard work.

"nodes": [
{
"requestedReviewer": {
"__typename": "user",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be valuable to also display teams among requested reviewers. But I also think that this is something that could just as well be a follow-up.

Copy link
Contributor Author

@doi-t doi-t Apr 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me create another follow-up PR for team! Since the key is different from user, I guess I need to tweak the sorting logic along with a query update.

Copy link
Contributor Author

@doi-t doi-t Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mislav
I've added the team reviewer support d70358e to this PR.

The following test results are made by below permissions (read:org works 👍 ).

-       q.Set("scope", "repo")
+       q.Set("scope", "repo read:org")

It seems that the requested team reviewer will be gone once one of the team members takes an action. The requested team will not be shown in the review results too because a result (Comment/Approved/Request changes) is always recorded with user account as far as I can see.

Screen Shot 2020-04-22 at 22 05 45

I also realized that ghost account does not have Login value. I added a workaround to show ghost's review results 67907c8.

Screen Shot 2020-04-22 at 22 17 05

I think this edge case is happening in other commands which display a user account. 🤔

@doi-t doi-t force-pushed the reviewers-in-pr-view branch from e046e12 to 1ce09ff Compare April 22, 2020 13:00
@doi-t doi-t requested a review from mislav April 22, 2020 13:24
@doi-t
Copy link
Contributor Author

doi-t commented Apr 29, 2020

I've merged master into this branch to include #786 and confirmed the work.

Screen Shot 2020-04-30 at 0 37 19

This PR is now ready for re-review and merge. #762 (comment) is additional changes since the last code review.

By the way, gh asked me to do auth again as I expected. However, it didn't work so that I needed to remove ~/.config/gh/config.yml.

$ gh pr view 1 --repo cli-test-org/cli-test
Notice: additional authorization required
Press Enter to open github.com in your browser...
Authentication complete. Press Enter to continue...

graphql error: 'Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:org', 'read:discussion'], but your token has only been granted the: ['repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.'

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update!

By the way, gh asked me to do auth again as I expected. However, it didn't work so that I needed to remove ~/.config/gh/config.yml.

Thanks for reporting that. I think that something in #786 with refreshing the token for the current process is off. 🤔 I will take a look.

Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants