@@ -16,6 +16,7 @@ import (
1616 api "code.gitea.io/gitea/modules/structs"
1717 "code.gitea.io/gitea/modules/web"
1818 "code.gitea.io/gitea/routers/api/v1/utils"
19+ "code.gitea.io/gitea/services/automerge"
1920 "code.gitea.io/gitea/services/context"
2021 "code.gitea.io/gitea/services/convert"
2122 issue_service "code.gitea.io/gitea/services/issue"
@@ -376,6 +377,11 @@ func CreatePullReview(ctx *context.APIContext) {
376377 return
377378 }
378379
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+
379385 // convert response
380386 apiReview , err := convert .ToPullReview (ctx , review , ctx .Doer )
381387 if err != nil {
@@ -464,6 +470,11 @@ func SubmitPullReview(ctx *context.APIContext) {
464470 return
465471 }
466472
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+
467478 // convert response
468479 apiReview , err := convert .ToPullReview (ctx , review , ctx .Doer )
469480 if err != nil {
@@ -880,7 +891,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
880891 ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
881892 return
882893 }
883- review , _ , isWrong := prepareSingleReview (ctx )
894+ review , pr , isWrong := prepareSingleReview (ctx )
884895 if isWrong {
885896 return
886897 }
@@ -890,7 +901,12 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
890901 return
891902 }
892903
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 )
894910 if err != nil {
895911 if pull_service .IsErrDismissRequestOnClosedPR (err ) {
896912 ctx .Error (http .StatusForbidden , "" , err )
@@ -900,6 +916,9 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
900916 return
901917 }
902918
919+ // as reviews could have blocked a pending automerge let's recheck
920+ automerge .MergeScheduledPullRequest (comm .Issue .PullRequest )
921+
903922 if review , err = issues_model .GetReviewByID (ctx , review .ID ); err != nil {
904923 ctx .Error (http .StatusInternalServerError , "GetReviewByID" , err )
905924 return
0 commit comments