@@ -16,6 +16,7 @@ import (
16
16
api "code.gitea.io/gitea/modules/structs"
17
17
"code.gitea.io/gitea/modules/web"
18
18
"code.gitea.io/gitea/routers/api/v1/utils"
19
+ "code.gitea.io/gitea/services/automerge"
19
20
"code.gitea.io/gitea/services/context"
20
21
"code.gitea.io/gitea/services/convert"
21
22
issue_service "code.gitea.io/gitea/services/issue"
@@ -376,6 +377,11 @@ func CreatePullReview(ctx *context.APIContext) {
376
377
return
377
378
}
378
379
380
+ // as a missing / blocking reviews could have blocked a pending automerge let's recheck
381
+ if reviewType == issues_model .ReviewTypeApprove {
382
+ automerge .MergeScheduledPullRequest (pr )
383
+ }
384
+
379
385
// convert response
380
386
apiReview , err := convert .ToPullReview (ctx , review , ctx .Doer )
381
387
if err != nil {
@@ -464,6 +470,11 @@ func SubmitPullReview(ctx *context.APIContext) {
464
470
return
465
471
}
466
472
473
+ // as a missing / blocking reviews could have blocked a pending automerge let's recheck
474
+ if review .Type == issues_model .ReviewTypeApprove {
475
+ automerge .MergeScheduledPullRequest (pr )
476
+ }
477
+
467
478
// convert response
468
479
apiReview , err := convert .ToPullReview (ctx , review , ctx .Doer )
469
480
if err != nil {
@@ -880,7 +891,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
880
891
ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
881
892
return
882
893
}
883
- review , _ , isWrong := prepareSingleReview (ctx )
894
+ review , pr , isWrong := prepareSingleReview (ctx )
884
895
if isWrong {
885
896
return
886
897
}
@@ -890,7 +901,12 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
890
901
return
891
902
}
892
903
893
- _ , err := pull_service .DismissReview (ctx , review .ID , ctx .Repo .Repository .ID , msg , ctx .Doer , isDismiss , dismissPriors )
904
+ if pr .Issue .IsClosed {
905
+ ctx .Error (http .StatusForbidden , "" , "not need to dismiss this review because this pr is closed" )
906
+ return
907
+ }
908
+
909
+ comm , err := pull_service .DismissReview (ctx , review .ID , ctx .Repo .Repository .ID , msg , ctx .Doer , isDismiss , dismissPriors )
894
910
if err != nil {
895
911
if pull_service .IsErrDismissRequestOnClosedPR (err ) {
896
912
ctx .Error (http .StatusForbidden , "" , err )
@@ -900,6 +916,9 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
900
916
return
901
917
}
902
918
919
+ // as reviews could have blocked a pending automerge let's recheck
920
+ automerge .MergeScheduledPullRequest (comm .Issue .PullRequest )
921
+
903
922
if review , err = issues_model .GetReviewByID (ctx , review .ID ); err != nil {
904
923
ctx .Error (http .StatusInternalServerError , "GetReviewByID" , err )
905
924
return
0 commit comments