aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-07-19 15:20:28 +0200
committerGitHub <noreply@github.com>2022-07-19 15:20:28 +0200
commitc0f5111fea0b742a60113e1bda81bf39607d6ca8 (patch)
tree78d8414ef40d6c4a2ddedfa7f71d10cee100feba /services
parente519249266cb69065b65f59477afa36f240b28cf (diff)
downloadgitea-c0f5111fea0b742a60113e1bda81bf39607d6ca8.tar.gz
gitea-c0f5111fea0b742a60113e1bda81bf39607d6ca8.zip
Dismiss prior pull reviews if done via web in review dismiss (#20197)
Diffstat (limited to 'services')
-rw-r--r--services/pull/review.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/services/pull/review.go b/services/pull/review.go
index 22e0ae9853..8d8903c6a9 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -20,6 +20,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/util"
)
// CreateCodeComment creates a comment on the code line
@@ -271,7 +272,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
}
// DismissReview dismissing stale review by repo admin
-func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss bool) (comment *issues_model.Comment, err error) {
+func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss, dismissPriors bool) (comment *issues_model.Comment, err error) {
review, err := issues_model.GetReviewByID(ctx, reviewID)
if err != nil {
return
@@ -295,6 +296,22 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
return
}
+ if dismissPriors {
+ reviews, err := issues_model.GetReviews(ctx, &issues_model.GetReviewOptions{
+ IssueID: review.IssueID,
+ ReviewerID: review.ReviewerID,
+ Dismissed: util.OptionalBoolFalse,
+ })
+ if err != nil {
+ return nil, err
+ }
+ for _, oldReview := range reviews {
+ if err = issues_model.DismissReview(oldReview, true); err != nil {
+ return nil, err
+ }
+ }
+ }
+
if !isDismiss {
return nil, nil
}