Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend refs/heads/ to issue template refs #20461

Merged
merged 24 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
42d2b83
Prepend refs/heads/ to issue template refs
zeripath Jul 23, 2022
17a2686
Merge branch 'main' into fix-20456-prepend-refs-heads
zeripath Oct 18, 2022
5e72df4
Merge branch 'main' into fix-20456-prepend-refs-heads
zeripath Oct 24, 2022
d884d8e
Merge branch 'main' into fix-20456-prepend-refs-heads
lafriks Oct 27, 2022
64d5282
Merge branch 'main' into fix-20456-prepend-refs-heads
wxiaoguang Nov 3, 2022
7195783
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 3, 2022
082ea35
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 4, 2022
e3afb9d
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 4, 2022
3313694
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 8, 2022
b2e9637
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 8, 2022
8cdba2b
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 9, 2022
ff439a9
Merge branch 'main' into fix-20456-prepend-refs-heads
zeripath Nov 9, 2022
5856890
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 11, 2022
8f2ea08
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 11, 2022
174501d
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 15, 2022
a2b69ed
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 15, 2022
b0a16a1
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 16, 2022
f300ffe
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 19, 2022
d8ea8fe
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 19, 2022
2d15925
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 19, 2022
4f8a912
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 21, 2022
1361d81
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 21, 2022
21a601e
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 22, 2022
c5919a7
Merge branch 'main' into fix-20456-prepend-refs-heads
lunny Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,9 @@ func (ctx *Context) IssueTemplatesFromDefaultBranch() []api.IssueTemplate {
}
it.Content = content
it.FileName = entry.Name()
if !strings.HasPrefix(it.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
lunny marked this conversation as resolved.
Show resolved Hide resolved
it.Ref = "refs/heads/" + it.Ref
}
if it.Valid() {
issueTemplates = append(issueTemplates, it)
}
Expand Down
3 changes: 3 additions & 0 deletions modules/git/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 !SHAPattern.MatchString(ref):
// assume they mean a branch
return repoURL + "/src/branch/" + refName
default:
return repoURL + "/src/commit/" + refName
}
Expand Down
4 changes: 4 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs,
}
}
}
if !strings.HasPrefix(meta.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
meta.Ref = "refs/heads/" + meta.Ref
}

ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
ctx.Data["Reference"] = meta.Ref
Expand Down
3 changes: 1 addition & 2 deletions services/issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"
)

// NewIssue creates new issue with labels for repository.
Expand Down Expand Up @@ -201,7 +200,7 @@ func GetRefEndNamesAndURLs(issues []*issues_model.Issue, repoLink string) (map[i
for _, issue := range issues {
if 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
Expand Down