pr status: show number of approvals#2261
pr status: show number of approvals#2261despreston wants to merge 3 commits intocli:trunkfrom despreston:des/approval-count
Conversation
mislav
left a comment
There was a problem hiding this comment.
Thanks for taking this on!
Let's discuss the design of the feature some more in the original issue thread, but as for the code in question, I've left a comment about correctly parsing Review records.
pkg/cmd/pr/status/status.go
Outdated
|
|
||
| for _, review := range pr.Reviews.Nodes { | ||
| if review.State == "APPROVED" { | ||
| totalApprovals++ |
There was a problem hiding this comment.
Note: this will count repeated approvals by the same person as multiple approvals.
I sometimes approve a single PR multiple times, usually to acknowledge that I've scanned over code updates since I've last reviewed. Multiple approvals from the same person should technically count as a single approval.
Moreover, if I leave 2 reviews where the first one is Approved and the second one is Request Changes, then my previous review should be discarded and should not qualify as an approval. Only the (chronologically) latest review status (other than a Comment status, which is neutral) from a single person should ever be taken into account.
See
Line 257 in c77e6af
|
@mislav Sorry to bother but do you have a timeline for when this can be reviewed again? |
|
|
In the discussion here it sounded like this could ship as I'm happy to help with this PR in any way I can. @despreston thanks for working on this 🚀 Having the count of approvals would make my life easier 😄 |
|
aha is that what the "n/x" means?? I would be happy to update this if that's what's needed, or hand it over to @alexcwatt if he wants to contribute to this. |
|
Sorry for the inactivity, y'all. We decided that if we were to ship this, we wanted to show |
|
@mislav Thanks for getting back - that makes sense. In my use case, the minimum hard requirement for the number of approvals of 1 is lower than the soft requirement of 2... so just seeing "Approved" wouldn't help me know which PR's I should still seek a second approval on. Perhaps there could be some sort of flag to show the counts always? |
I see! That's a good counterpoint, thank you. Let's then go with "N Approved" when the base branch has no minimum approval requirements, and "N/X Approved" otherwise. From a linguistic perspective, "N Approval(s)" would be more correct, but then we would have think about pluralization rules in the "N/X" case, so let's just not go there right now and stick with "Approved". |
|
That sounds great @mislav! @despreston If you're able to update this that would be awesome. Otherwise I will get to it later (literally getting married tomorrow so not for a little while! 💒). |
|
I can take this on. Should have something by next week. |
This commit changes the approval count in the PR status command so that it only counts the most recent review from each reviewer.
If the base branch has no minimum approval requirements, show "N Approved" reviews. Otherwise, show "N/X Approved".
|
@mislav Pushed a change but I'm still not 100% I read the api correctly. If that's the case, lmk and I can dig in again. |
|
lol this is silly as hell but I deleted this branch locally, then changed my mind, and now I can't figure out how to push the changes to this branch. Here are the steps I took:
https://github.com/despreston/cli/tree/des/approval-count is the branch with the latest changes. I just needed to fix that latest merge conflict. |
|
|
@despreston You have deleted the head branch; therefore this PR had stopped receiving updates from your fork. It doesn't matter that you later pushed the branch again—I don't think the PR can be "fixed" again. Please open a new PR! |
|
Lesson learned: don't delete the head branch before the thing is merged. |
closes #2210
This commit adds the total count of PR approvals in the
pr statuscommand output.