diff options
author | zeripath <art27@cantab.net> | 2023-01-13 22:33:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 16:33:35 -0600 |
commit | d0c74dd2d23cf3f473fcf4bc784242334c714faa (patch) | |
tree | 3f0ee330190df94480fd59e4b3f9fb79402bdfdb /modules | |
parent | 2f91a12143e8c33d896c794d470b98fddb572500 (diff) | |
download | gitea-d0c74dd2d23cf3f473fcf4bc784242334c714faa.tar.gz gitea-d0c74dd2d23cf3f473fcf4bc784242334c714faa.zip |
Prepend refs/heads/ to issue template refs (#20461) (#22427)
Backport #20461
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/context/repo.go | 3 | ||||
-rw-r--r-- | modules/git/utils.go | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 3e2f794303..3bf6431e2c 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -1087,6 +1087,9 @@ func (ctx *Context) IssueTemplatesErrorsFromDefaultBranch() ([]*api.IssueTemplat if it, err := template.UnmarshalFromEntry(entry, dirName); err != nil { invalidFiles[fullName] = err } else { + if !strings.HasPrefix(it.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref> + it.Ref = git.BranchPrefix + it.Ref + } issueTemplates = append(issueTemplates, it) } } diff --git a/modules/git/utils.go b/modules/git/utils.go index d6bf9f4413..a439dabae1 100644 --- a/modules/git/utils.go +++ b/modules/git/utils.go @@ -100,6 +100,9 @@ func RefURL(repoURL, ref string) string { return repoURL + "/src/branch/" + refName case strings.HasPrefix(ref, TagPrefix): return repoURL + "/src/tag/" + refName + case !IsValidSHAPattern(ref): + // assume they mean a branch + return repoURL + "/src/branch/" + refName default: return repoURL + "/src/commit/" + refName } |