From 1f45b3a629c0799359faa7d4e892522a191c9682 Mon Sep 17 00:00:00 2001 From: Norwin Date: Sun, 3 Oct 2021 05:11:17 +0200 Subject: API: don't allow merged PRs to be reopened (#17192) * api: dont open merged PRs * don't change base branch when already merged * don't allow any state change * also validate opening merged PRs in EditIssue Co-authored-by: John Olheiser Co-authored-by: 6543 <6543@obermui.de> --- routers/api/v1/repo/issue.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'routers/api/v1/repo/issue.go') diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 7b97a5683a..17a3becd5b 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -790,6 +790,15 @@ func EditIssue(ctx *context.APIContext) { } } if form.State != nil { + if issue.IsPull { + if pr, err := issue.GetPullRequest(); err != nil { + ctx.Error(http.StatusInternalServerError, "GetPullRequest", err) + return + } else if pr.HasMerged { + ctx.Error(http.StatusPreconditionFailed, "MergedPRState", "cannot change state of this pull request, it was already merged") + return + } + } issue.IsClosed = api.StateClosed == api.StateType(*form.State) } statusChangeComment, titleChanged, err := models.UpdateIssueByAPI(issue, ctx.User) -- cgit v1.2.3