aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/review.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issues/review.go')
-rw-r--r--models/issues/review.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/models/issues/review.go b/models/issues/review.go
index ae4029e80f..d8e517ad3c 100644
--- a/models/issues/review.go
+++ b/models/issues/review.go
@@ -263,15 +263,17 @@ func IsOfficialReviewer(ctx context.Context, issue *Issue, reviewers ...*user_mo
if err != nil {
return false, err
}
- if err = pr.LoadProtectedBranch(ctx); err != nil {
+
+ rule, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pr.BaseRepoID, pr.BaseBranch)
+ if err != nil {
return false, err
}
- if pr.ProtectedBranch == nil {
+ if rule == nil {
return false, nil
}
for _, reviewer := range reviewers {
- official, err := git_model.IsUserOfficialReviewer(ctx, pr.ProtectedBranch, reviewer)
+ official, err := git_model.IsUserOfficialReviewer(ctx, rule, reviewer)
if official || err != nil {
return official, err
}
@@ -286,18 +288,19 @@ func IsOfficialReviewerTeam(ctx context.Context, issue *Issue, team *organizatio
if err != nil {
return false, err
}
- if err = pr.LoadProtectedBranch(ctx); err != nil {
+ pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pr.BaseRepoID, pr.BaseBranch)
+ if err != nil {
return false, err
}
- if pr.ProtectedBranch == nil {
+ if pb == nil {
return false, nil
}
- if !pr.ProtectedBranch.EnableApprovalsWhitelist {
+ if !pb.EnableApprovalsWhitelist {
return team.UnitAccessMode(ctx, unit.TypeCode) >= perm.AccessModeWrite, nil
}
- return base.Int64sContains(pr.ProtectedBranch.ApprovalsWhitelistTeamIDs, team.ID), nil
+ return base.Int64sContains(pb.ApprovalsWhitelistTeamIDs, team.ID), nil
}
// CreateReview creates a new review based on opts