From ec35af470c8cbed9f32b68e1a2c43e0f71c5f97b Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Sun, 16 Jul 2023 07:10:49 +0900 Subject: [PATCH] Avoid opening/closing PRs which are already merged (#25883) We can select PRs to open/close them by one click, but we forgot to check whether it is merged. You can get an opening merged PR: ![image](https://github.com/go-gitea/gitea/assets/18380374/22c2e747-4bb9-4742-a9aa-ef39d5308bc5) You can confirm this in: https://try.gitea.io/yp05327/testrepo/pulls/5 --- routers/web/repo/issue.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 31bcbd7c21..bd8959846c 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2762,7 +2762,15 @@ func UpdateIssueStatus(ctx *context.Context) { ctx.ServerError("LoadRepositories", err) return } + if err := issues.LoadPullRequests(ctx); err != nil { + ctx.ServerError("LoadPullRequests", err) + return + } + for _, issue := range issues { + if issue.IsPull && issue.PullRequest.HasMerged { + continue + } if issue.IsClosed != isClosed { if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil { if issues_model.IsErrDependenciesLeft(err) {