@@ -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 {
@@ -879,7 +890,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
879
890
ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
880
891
return
881
892
}
882
- review , _ , isWrong := prepareSingleReview (ctx )
893
+ review , pr , isWrong := prepareSingleReview (ctx )
883
894
if isWrong {
884
895
return
885
896
}
@@ -889,7 +900,12 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
889
900
return
890
901
}
891
902
892
- _ , err := pull_service .DismissReview (ctx , review .ID , ctx .Repo .Repository .ID , msg , ctx .Doer , isDismiss , dismissPriors )
903
+ if pr .Issue .IsClosed {
904
+ ctx .Error (http .StatusForbidden , "" , "not need to dismiss this review because this pr is closed" )
905
+ return
906
+ }
907
+
908
+ comm , err := pull_service .DismissReview (ctx , review .ID , ctx .Repo .Repository .ID , msg , ctx .Doer , isDismiss , dismissPriors )
893
909
if err != nil {
894
910
if pull_service .IsErrDismissRequestOnClosedPR (err ) {
895
911
ctx .Error (http .StatusForbidden , "" , err )
@@ -899,6 +915,9 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
899
915
return
900
916
}
901
917
918
+ // as reviews could have blocked a pending automerge let's recheck
919
+ automerge .MergeScheduledPullRequest (comm .Issue .PullRequest )
920
+
902
921
if review , err = issues_model .GetReviewByID (ctx , review .ID ); err != nil {
903
922
ctx .Error (http .StatusInternalServerError , "GetReviewByID" , err )
904
923
return
0 commit comments