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

Show review labels in the pull request lists #9274

Closed

Conversation

oscarcosta
Copy link
Contributor

Show review labels (Review required, Approved and Changes requested) in the pull request lists. Related to issue #8257

Screenshot from 2019-12-06 17-56-29

Screenshot from 2019-12-06 17-56-41

Screenshot from 2019-12-06 17-56-52

@codecov-io
Copy link

codecov-io commented Dec 7, 2019

Codecov Report

Merging #9274 into master will increase coverage by 0.16%.
The diff coverage is 40.47%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
routers/org/home.go 65.68% <ø> (-0.34%) ⬇️
routers/routes/routes.go 86.57% <ø> (+0.04%) ⬆️
routers/org/setting.go 0% <ø> (ø) ⬆️
models/helper_environment.go 90% <ø> (ø) ⬆️
models/migrations/migrations.go 4.16% <ø> (ø) ⬆️
routers/api/v1/org/member.go 16.01% <0%> (ø) ⬆️
routers/init.go 63.04% <0%> (-2.13%) ⬇️
models/migrations/v127.go 0% <0%> (ø)
modules/graceful/manager_unix.go 40.83% <0%> (ø) ⬆️
cmd/serv.go 2.84% <0%> (-0.05%) ⬇️
... and 61 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64b47d5...01bd93c. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 7, 2019
Copy link
Contributor

@bagasme bagasme left a 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.

@lunny lunny added the type/enhancement An improvement of existing functionality label Dec 7, 2019
@lunny lunny added this to the 1.12.0 milestone Dec 7, 2019
@lunny
Copy link
Member

lunny commented Dec 7, 2019

@oscarcosta If you can show approved count, that's better! I found github didn't show that.

models/pull.go Outdated Show resolved Hide resolved
options/locale/locale_cs-CZ.ini Outdated Show resolved Hide resolved
@oscarcosta
Copy link
Contributor Author

Review labels with counters:
Screenshot from 2019-12-07 00-06-27

models/pull.go Outdated
if pr.ProtectedBranch.GetRejectedReviewsCount(pr) > 0 {
return i18n.Tr(lang, "repo.pulls.review_rejected", rejections)
}
approvals := pr.ProtectedBranch.GetGrantedApprovalsCount(pr)
Copy link
Member

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.

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 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.

Copy link
Member

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. 😄

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

@davidsvantesson davidsvantesson left a 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?

options/locale/locale_es-ES.ini Outdated Show resolved Hide resolved
routers/user/home.go Show resolved Hide resolved
templates/repo/issue/list.tmpl Show resolved Hide resolved
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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried to display these counters after the label. Does it seems right?
Screenshot from 2019-12-08 11-22-35

Copy link
Member

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.

templates/repo/issue/milestone_issues.tmpl Show resolved Hide resolved
templates/user/dashboard/issues.tmpl Show resolved Hide resolved
templates/user/dashboard/issues.tmpl Outdated Show resolved Hide resolved
models/issue.go Outdated Show resolved Hide resolved
models/branches.go Outdated Show resolved Hide resolved
models/issue_list.go Outdated Show resolved Hide resolved
@6543
Copy link
Member

6543 commented Feb 2, 2020

@oscarcosta can you resolve change-requests and conflicts pleace

@oscarcosta
Copy link
Contributor Author

@6543 sure, I can work on that today.

models/pull.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 3, 2020
models/pull.go Outdated Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented Feb 3, 2020

Two nit things will make this better.

  • like what @lafrks said return a status. And you could also check if ConflictedFiles length to return conflicted status.
  • batch load protected branch or other objects on pull_list.go for a performance consideration.

@oscarcosta
Copy link
Contributor Author

Hi @lunny,
Wouldn't the conflict status be slightly different from the review status? Perhaps a different label in the pull request list.

Copy link
Member

@lunny lunny left a 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 {
Copy link
Member

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.

Copy link
Contributor

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)

Copy link
Member

@lunny lunny Feb 13, 2020

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

@lunny
Copy link
Member

lunny commented Feb 23, 2020

We just should use select status, count(status) from review where ... and is_offcial=true group by status. Because is_offcial means official reviewers' last review.

@oscarcosta
Copy link
Contributor Author

Hi @lunny,
I tried to load the pull request attributes in batch, calling the methods in the loadAttributes in pull_list.go. However, the PullRequests are loaded as Issues with the isPull attribute setted (see files routers/user/home.go and routers/repo/issue.go), so I called the PullRequest.LoadAttributes in those places.

@oscarcosta
Copy link
Contributor Author

We just should use select status, count(status) from review where ... and is_offcial=true group by status. Because is_offcial means official reviewers' last review.

About this query, would it replace both GetRejectedReviewsCount and GetGrantedApprovalsCount methods in GetReviewStatus?

@stale
Copy link

stale bot commented Apr 25, 2020

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.

@stale stale bot added the issue/stale label Apr 25, 2020
@6543
Copy link
Member

6543 commented Apr 25, 2020

Whats the status of this?

@stale stale bot removed the issue/stale label Apr 25, 2020
@oscarcosta
Copy link
Contributor Author

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.

@6543
Copy link
Member

6543 commented Apr 26, 2020

@oscarcosta I couldn't find the specific pull but its arlready implemented:

Bildschirmfoto zu 2020-04-26 15-59-36

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.