-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Show review labels in the pull request lists #9274
Show review labels in the pull request lists #9274
Conversation
… - in the pull request lists. Related to issue go-gitea#8257
Codecov Report
@@ Coverage Diff @@
## master #9274 +/- ##
==========================================
+ Coverage 43.38% 43.54% +0.16%
==========================================
Files 575 583 +8
Lines 79683 80296 +613
==========================================
+ Hits 34567 34967 +400
- Misses 40832 40991 +159
- Partials 4284 4338 +54
Continue to review full report at Codecov.
|
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.
Related strings for some locales are same as on en-US
locale.
@oscarcosta If you can show approved count, that's better! I found github didn't show that. |
models/pull.go
Outdated
if pr.ProtectedBranch.GetRejectedReviewsCount(pr) > 0 { | ||
return i18n.Tr(lang, "repo.pulls.review_rejected", rejections) | ||
} | ||
approvals := pr.ProtectedBranch.GetGrantedApprovalsCount(pr) |
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 think that a PR that has been repeatedly approved and rejected from one reviewer should count only one approval or one rejection, depending on which happened last:
- Reviewer 1: approves, requests changes = 0 approvals, 1 change requests
- Reviewer 2: approves = 1 approval, 0 change requests
- Reviewer 3: requests changes, requests changes, requests changes, approves = 1 approvals, 0 change requests
- Reviewer 4: requests changes = 0 approvals, 1 change requests
Grand total: 2 approvals, 2 change requests
To achieve that, IMHO all counts (approvals, rejections) should be processed in the same database query. Check this comment (and other reviews of mine in that PR) for examples on how to achieve that.
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 think that is already achieved. Both GetGrantedApprovalsCount
and GetRejectedReviewsCount
only counts reviews that are official, and official reviews are only the latest review (approval or rejection) of users that are in the whitelist.
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.
Duh, I forgot about the official
property! I had a rough week... I need some rest. 😄
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 could use different color tag for approved counter and requested counter. Even the approval requirement. 1/2
means this PR require 2 approvals but has 1 approved.
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 should approve or request change.
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.
In general I think this PR looks good!
One issue is that we haven't implemented blocking PR on changes requested yet (#9130), so the list will say "Changes requested" although it will not block merging. I think it would be easy to implement that after this PR though.
I think we need to decide how it should work:
- If changes are requested it will always block merging (no option for it). For me this would be OK and makes sense, though it would be a breaking change.
- Have a branch protection option whether requested changes shall block merging. In that case I don't know if it should say "Changes Requested" in the PR list, don't make sense if it isn't blocking?
models/pull.go
Outdated
// GetReviewLabel returns the formatted review label with counter for the review of this pull request | ||
func (pr *PullRequest) GetReviewLabel(lang string) string { | ||
if pr.RequiresApproval() { | ||
rejections := pr.ProtectedBranch.GetRejectedReviewsCount(pr) |
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.
IMHO we should display # of changes requested and approvals. That would solve the problem of whether the change requests are blocking or not.
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.
It's incomplete information. The PR can have 17 approvals and 1 change request. Should it show "1 changes requested" or "17 people approved this"? I think both.
@oscarcosta can you resolve change-requests and conflicts pleace |
@6543 sure, I can work on that today. |
# Conflicts: # models/branches.go # models/pull.go # options/locale/locale_en-US.ini
…g the i18n from the model.
…tedApprovalsCount from ProtectedBranch to PullRequest.
Two nit things will make this better.
|
Hi @lunny, |
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 think this is the last one thought from me. Otherwise LGTM.
} | ||
|
||
// GetReviewStatus returns a ReviewStatusCount of this pull request | ||
func (pr *PullRequest) GetReviewStatus() ReviewStatusCount { |
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.
If someone sent a rejected review and after that send another approval review. We should only count 1 approval but 0 rejected.
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 is in the official
column which is accounted for, only last review of a reviewer can be official. (The reviewer shall also be in the review whitelist)
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.
official
means this review could be counted as approvals but it don't mean it's the last review of the official reviewer. See https://github.com/go-gitea/gitea/blob/master/models/review.go#L57-L58
We just should use |
Hi @lunny, |
About this query, would it replace both GetRejectedReviewsCount and GetGrantedApprovalsCount methods in GetReviewStatus? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
Whats the status of this? |
Sorry, but I think I will not be able to finish it. If anyone wants to finish it, go ahead. |
@oscarcosta I couldn't find the specific pull but its arlready implemented: |
Show review labels (Review required, Approved and Changes requested) in the pull request lists. Related to issue #8257