From fd7ebaaa9cba1b14c871d27dcb688d1807495f2f Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 19 Jan 2023 11:17:44 -0600 Subject: [PATCH] Fix issue not auto-closing when it includes a reference to a branch (#22514) (#22521) Backport #22514 Co-authored-by: Brecht Van Lommel --- services/issue/commit.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/issue/commit.go b/services/issue/commit.go index c8cfa6cc8a..b17f0e952c 100644 --- a/services/issue/commit.go +++ b/services/issue/commit.go @@ -19,6 +19,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" + "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/references" "code.gitea.io/gitea/modules/repository" @@ -176,7 +177,8 @@ func UpdateIssuesCommit(doer *user_model.User, repo *repo_model.Repository, comm 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 != "" { - if branchName != refIssue.Ref { + issueBranchName := strings.TrimPrefix(refIssue.Ref, git.BranchPrefix) + if branchName != issueBranchName { continue } // Otherwise, only process commits to the default branch