Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-24 02:36:10 +01:00

Avoid opening/closing PRs which are already merged (#25883) (#25903)

Backport #25883 by @yp05327

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

Co-authored-by: yp05327 <576951401@qq.com>
(cherry picked from commit 9159964ada)
This commit is contained in:
Giteabot 2023-07-17 08:14:22 -04:00 committed by Earl Warren
parent d1ed7ea9e3
commit 27a40aeb6b
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -2729,7 +2729,15 @@ func UpdateIssueStatus(ctx *context.Context) {
ctx.ServerError("LoadRepositories", err) ctx.ServerError("LoadRepositories", err)
return return
} }
if err := issues.LoadPullRequests(ctx); err != nil {
ctx.ServerError("LoadPullRequests", err)
return
}
for _, issue := range issues { for _, issue := range issues {
if issue.IsPull && issue.PullRequest.HasMerged {
continue
}
if issue.IsClosed != isClosed { if issue.IsClosed != isClosed {
if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil { if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil {
if issues_model.IsErrDependenciesLeft(err) { if issues_model.IsErrDependenciesLeft(err) {