File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,12 @@ func (protectBranch *ProtectedBranch) HasEnoughApprovals(pr *PullRequest) bool {
99
99
100
100
// GetGrantedApprovalsCount returns the number of granted approvals for pr. A granted approval must be authored by a user in an approval whitelist.
101
101
func (protectBranch * ProtectedBranch ) GetGrantedApprovalsCount (pr * PullRequest ) int64 {
102
- reviews , err := GetReviewersByPullID (pr .ID )
102
+ reviews , err := GetReviewersByPullID (pr .Issue . ID )
103
103
if err != nil {
104
104
log .Error (1 , "GetUniqueApprovalsByPullRequestID:" , err )
105
105
return 0
106
106
}
107
+
107
108
approvals := int64 (0 )
108
109
userIDs := make ([]int64 , 0 )
109
110
for _ , review := range reviews {
Original file line number Diff line number Diff line change @@ -776,6 +776,7 @@ func ViewIssue(ctx *context.Context) {
776
776
777
777
if issue .IsPull {
778
778
pull := issue .PullRequest
779
+ pull .Issue = issue
779
780
canDelete := false
780
781
781
782
if ctx .IsSigned {
@@ -833,8 +834,9 @@ func ViewIssue(ctx *context.Context) {
833
834
return
834
835
}
835
836
if pull .ProtectedBranch != nil {
836
- ctx .Data ["IsBlockedByApprovals" ] = ! pull .ProtectedBranch .HasEnoughApprovals (pull )
837
- ctx .Data ["GrantedApprovals" ] = pull .ProtectedBranch .GetGrantedApprovalsCount (pull )
837
+ cnt := pull .ProtectedBranch .GetGrantedApprovalsCount (pull )
838
+ ctx .Data ["IsBlockedByApprovals" ] = pull .ProtectedBranch .RequiredApprovals > 0 && cnt < pull .ProtectedBranch .RequiredApprovals
839
+ ctx .Data ["GrantedApprovals" ] = cnt
838
840
}
839
841
ctx .Data ["IsPullBranchDeletable" ] = canDelete && pull .HeadRepo != nil && git .IsBranchExist (pull .HeadRepo .RepoPath (), pull .HeadBranch )
840
842
You can’t perform that action at this time.
0 commit comments