From e0a8965208f17c8f037e5489d28f1a070e2d8b47 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jan 2023 22:50:22 +0100 Subject: [PATCH] Fix invalid issue branch reference if not specified in template (#22513) When an issue template does not contain a ref, it would end up with an invalid `ref/heads/` value instead of having no branch referenced . --- 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 b081092c57f..59ab717a1dd 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -784,7 +784,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