summaryrefslogtreecommitdiffstats
path: root/services/pull/pull.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-07-20 15:18:52 +0800
committerGitHub <noreply@github.com>2023-07-20 15:18:52 +0800
commit01c04607c76391e09620c6f2475b722207d2ee73 (patch)
treeff1cdb3ef3b37f6e8ab3108999e1def1215414fe /services/pull/pull.go
parentcf467119ffa82177258226fd04946a2105ee7aa0 (diff)
downloadgitea-01c04607c76391e09620c6f2475b722207d2ee73.tar.gz
gitea-01c04607c76391e09620c6f2475b722207d2ee73.zip
Fix bug when pushing to a pull request which enabled dismiss approval automatically (#25882)
Fix #25858 The option `dissmiss stale approvals` was listed on protected branch but never implemented. This PR fixes that. <img width="1006" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/60bfa968-4db7-4c24-b8be-2e5978f91bb9"> <img width="1021" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/8dabc14d-2dfe-40c2-94ed-24fcbf6e0e8f">
Diffstat (limited to 'services/pull/pull.go')
-rw-r--r--services/pull/pull.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 0f562b9ee3..5f55a36f33 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -309,6 +309,17 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
if err := issues_model.MarkReviewsAsStale(pr.IssueID); err != nil {
log.Error("MarkReviewsAsStale: %v", err)
}
+
+ // dismiss all approval reviews if protected branch rule item enabled.
+ pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pr.BaseRepoID, pr.BaseBranch)
+ if err != nil {
+ log.Error("GetFirstMatchProtectedBranchRule: %v", err)
+ }
+ if pb != nil && pb.DismissStaleApprovals {
+ if err := DismissApprovalReviews(ctx, doer, pr); err != nil {
+ log.Error("DismissApprovalReviews: %v", err)
+ }
+ }
}
if err := issues_model.MarkReviewsAsNotStale(pr.IssueID, newCommitID); err != nil {
log.Error("MarkReviewsAsNotStale: %v", err)