From fa332711575adb54e1c5d78e151dd53c8a67530a Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 19 Jan 2023 09:39:30 -0600 Subject: [PATCH] Fix invalid issue branch reference if not specified in template (#22513) (#22520) Backport #22513 Co-authored-by: Brecht Van Lommel --- routers/web/repo/issue.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 2af3d9c43..82abc85a1 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -786,7 +786,8 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles } } - if !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/ + + if template.Ref != "" && !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/ template.Ref = git.BranchPrefix + template.Ref } ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0