summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
authorKemal Zebari <60799661+kemzeb@users.noreply.github.com>2024-04-27 04:55:03 -0700
committerGitHub <noreply@github.com>2024-04-27 11:55:03 +0000
commitdd301cae1c40c9ef2805bd13af6b09a81ff4f5d7 (patch)
tree9ce20393f8f1ee28493aa52400b0b68cc4cd439c /routers/api/v1/repo
parent238eb3ff9f36bcf7b4637957ae2dd98446105894 (diff)
downloadgitea-dd301cae1c40c9ef2805bd13af6b09a81ff4f5d7.tar.gz
gitea-dd301cae1c40c9ef2805bd13af6b09a81ff4f5d7.zip
Prevent allow/reject reviews on merged/closed PRs (#30686)
Resolves #30675.
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r--routers/api/v1/repo/pull_review.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go
index b527e90f10..4b481790fb 100644
--- a/routers/api/v1/repo/pull_review.go
+++ b/routers/api/v1/repo/pull_review.go
@@ -4,6 +4,7 @@
package repo
import (
+ "errors"
"fmt"
"net/http"
"strings"
@@ -372,7 +373,11 @@ func CreatePullReview(ctx *context.APIContext) {
// create review and associate all pending review comments
review, _, err := pull_service.SubmitReview(ctx, ctx.Doer, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, opts.CommitID, nil)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
+ if errors.Is(err, pull_service.ErrSubmitReviewOnClosedPR) {
+ ctx.Error(http.StatusUnprocessableEntity, "", err)
+ } else {
+ ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
+ }
return
}
@@ -460,7 +465,11 @@ func SubmitPullReview(ctx *context.APIContext) {
// create review and associate all pending review comments
review, _, err = pull_service.SubmitReview(ctx, ctx.Doer, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, headCommitID, nil)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
+ if errors.Is(err, pull_service.ErrSubmitReviewOnClosedPR) {
+ ctx.Error(http.StatusUnprocessableEntity, "", err)
+ } else {
+ ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
+ }
return
}