enhance: allow auto-closing PRs from PRs (#39393)

On GitHub, one can close PRs via `Fixes: #123` references which was not
possible on Gitea before, but now is. Verified fully that behaviour
matches GH and ensured no regressions for external trackers.
This commit is contained in:
silverwind
2026-09-25 11:35:13 +00:00
committed by GitHub
parent 455f30a7b6
commit 6d59229331
5 changed files with 42 additions and 8 deletions
+8 -2
View File
@@ -18,6 +18,7 @@ import (
issues_model "gitea.dev/models/issues"
access_model "gitea.dev/models/perm/access"
repo_model "gitea.dev/models/repo"
"gitea.dev/models/unit"
user_model "gitea.dev/models/user"
"gitea.dev/modules/container"
"gitea.dev/modules/git"
@@ -188,8 +189,8 @@ func UpdateIssuesCommit(ctx context.Context, doer *user_model.User, repo *repo_m
return err
}
// Only issues can be closed/reopened this way, and user needs the correct permissions
if refIssue.IsPull || !canclose {
// Only issues can be reopened this way, and user needs the correct permissions
if !canclose || (refIssue.IsPull && ref.Action == references.XRefActionReopens) {
continue
}
@@ -198,6 +199,11 @@ func UpdateIssuesCommit(ctx context.Context, doer *user_model.User, repo *repo_m
continue
}
// With an external tracker, pull requests are referenced as "!N"
if !ref.IsPull && refIssue.IsPull && refRepo.UnitEnabled(ctx, unit.TypeExternalTracker) {
continue
}
if !repo.CloseIssuesViaCommitInAnyBranch {
// If the issue was specified to be in a particular branch, don't allow commits in other branches to close it
if refIssue.Ref != "" {