-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Show review labels in the pull request lists #9274
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
Changes from 4 commits
d9f1bbf
4ff5406
46b9e29
8236a04
6686bd7
3761e06
582d7ef
d723929
9a6f4a8
f670132
3c16eea
3f93cfe
d3657fd
deca4a8
4f792ec
fbd4c09
64b47d5
b3ef97e
01bd93c
f84ce89
eea70d5
6577c95
d97dc25
c63d0a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import ( | |
| "code.gitea.io/gitea/modules/timeutil" | ||
|
|
||
| "github.com/unknwon/com" | ||
| "github.com/unknwon/i18n" | ||
| ) | ||
|
|
||
| var pullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength) | ||
|
|
@@ -176,6 +177,39 @@ func (pr *PullRequest) loadProtectedBranch(e Engine) (err error) { | |
| return | ||
| } | ||
|
|
||
| func (pr *PullRequest) requiredApprovals() int64 { | ||
| if pr.ProtectedBranch == nil { | ||
| if err := pr.loadProtectedBranch(x); err != nil { | ||
| log.Error("Error loading ProtectedBranch", err) | ||
| } | ||
| } | ||
| if pr.ProtectedBranch != nil { | ||
| return pr.ProtectedBranch.RequiredApprovals | ||
| } | ||
| return 0 | ||
| } | ||
|
|
||
| // RequiresApproval returns true if this pull request requires approval, otherwise returns false | ||
| func (pr *PullRequest) RequiresApproval() bool { | ||
| return pr.requiredApprovals() > 0 | ||
| } | ||
|
|
||
| // 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) | ||
|
||
| if pr.ProtectedBranch.GetRejectedReviewsCount(pr) > 0 { | ||
oscarcosta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return i18n.Tr(lang, "repo.pulls.review_rejected", rejections) | ||
oscarcosta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| approvals := pr.ProtectedBranch.GetGrantedApprovalsCount(pr) | ||
|
||
| if approvals >= pr.ProtectedBranch.RequiredApprovals { | ||
| return i18n.Tr(lang, "repo.pulls.review_approved", approvals) | ||
| } | ||
| return i18n.Tr(lang, "repo.pulls.review_required", pr.ProtectedBranch.RequiredApprovals-approvals) | ||
| } | ||
| return i18n.Tr(lang, "repo.pulls.review_approved", 0) // by default | ||
| } | ||
|
|
||
| // GetDefaultMergeMessage returns default message used when merging pull request | ||
| func (pr *PullRequest) GetDefaultMergeMessage() string { | ||
| if pr.HeadRepo == nil { | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.