1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-19 08:48:37 +00:00

API: don't allow merged PRs to be reopened (#17271)

This commit is contained in:
Norwin
2021-10-08 19:54:26 +02:00
committed by GitHub
parent 245596e130
commit c927ebd119
2 changed files with 14 additions and 1 deletions

View File

@@ -584,6 +584,10 @@ func EditPullRequest(ctx *context.APIContext) {
}
if form.State != nil {
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)
@@ -605,7 +609,7 @@ func EditPullRequest(ctx *context.APIContext) {
}
// change pull target branch
if len(form.Base) != 0 && form.Base != pr.BaseBranch {
if !pr.HasMerged && len(form.Base) != 0 && form.Base != pr.BaseBranch {
if !ctx.Repo.GitRepo.IsBranchExist(form.Base) {
ctx.Error(http.StatusNotFound, "NewBaseBranchNotExist", fmt.Errorf("new base '%s' not exist", form.Base))
return