mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-30 00:01:24 +00:00
Backport #20461 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
2f91a12143
commit
d0c74dd2d2
|
@ -1087,6 +1087,9 @@ func (ctx *Context) IssueTemplatesErrorsFromDefaultBranch() ([]*api.IssueTemplat
|
||||||
if it, err := template.UnmarshalFromEntry(entry, dirName); err != nil {
|
if it, err := template.UnmarshalFromEntry(entry, dirName); err != nil {
|
||||||
invalidFiles[fullName] = err
|
invalidFiles[fullName] = err
|
||||||
} else {
|
} 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)
|
issueTemplates = append(issueTemplates, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,9 @@ func RefURL(repoURL, ref string) string {
|
||||||
return repoURL + "/src/branch/" + refName
|
return repoURL + "/src/branch/" + refName
|
||||||
case strings.HasPrefix(ref, TagPrefix):
|
case strings.HasPrefix(ref, TagPrefix):
|
||||||
return repoURL + "/src/tag/" + refName
|
return repoURL + "/src/tag/" + refName
|
||||||
|
case !IsValidSHAPattern(ref):
|
||||||
|
// assume they mean a branch
|
||||||
|
return repoURL + "/src/branch/" + refName
|
||||||
default:
|
default:
|
||||||
return repoURL + "/src/commit/" + refName
|
return repoURL + "/src/commit/" + refName
|
||||||
}
|
}
|
||||||
|
|
|
@ -784,6 +784,10 @@ 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/<ref>
|
||||||
|
template.Ref = git.BranchPrefix + template.Ref
|
||||||
}
|
}
|
||||||
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
|
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
|
||||||
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
|
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/notification"
|
"code.gitea.io/gitea/modules/notification"
|
||||||
"code.gitea.io/gitea/modules/storage"
|
"code.gitea.io/gitea/modules/storage"
|
||||||
"code.gitea.io/gitea/modules/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewIssue creates new issue with labels for repository.
|
// NewIssue creates new issue with labels for repository.
|
||||||
|
@ -201,7 +200,7 @@ func GetRefEndNamesAndURLs(issues []*issues_model.Issue, repoLink string) (map[i
|
||||||
for _, issue := range issues {
|
for _, issue := range issues {
|
||||||
if issue.Ref != "" {
|
if issue.Ref != "" {
|
||||||
issueRefEndNames[issue.ID] = git.RefEndName(issue.Ref)
|
issueRefEndNames[issue.ID] = git.RefEndName(issue.Ref)
|
||||||
issueRefURLs[issue.ID] = git.RefURL(repoLink, util.PathEscapeSegments(issue.Ref))
|
issueRefURLs[issue.ID] = git.RefURL(repoLink, issue.Ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return issueRefEndNames, issueRefURLs
|
return issueRefEndNames, issueRefURLs
|
||||||
|
|
Loading…
Reference in a new issue