diff options
author | Sijmen Schoon <me@sijmenschoon.nl> | 2020-05-15 00:55:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 18:55:43 -0400 |
commit | 66a9ef90362db1280808ff74e40c2e670f992fcb (patch) | |
tree | 72b9142052f9923e48796e0d01823e78f3529484 /routers | |
parent | 591ca030f0393addee619c17e61d8b9513e2bb05 (diff) | |
download | gitea-66a9ef90362db1280808ff74e40c2e670f992fcb.tar.gz gitea-66a9ef90362db1280808ff74e40c2e670f992fcb.zip |
Fix ref links in issue overviews for tags (#8742)
* Properly generate ref URLs
Tags used to not generate correct URLs (src/branch/tags/1.0.0 instead of
src/tags/1.0.0).
Also cleans up some code around it with the created helper functions.
* Fix formatting and create migration
* Add copyright head to utils_test
* Use a raw query for the ref migration
* Remove semicolon
* Quote column and table names in migration SQL
* Change || to CONCAT, since MSSQL does not support ||
* Make migration engine aware
* Add missing import
* Move ref EndName and URL to the issue service
* Fix tests
* Add test for commit refs
* Update issue.go
* Use the right command for building JavaScript bundles
* Prepare for merge
* Check for refs/* before prepending in migration
* Update services/issue/issue_test.go
* Update modules/git/utils_test.go
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: techknowlogick <matti@mdranta.net>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/issue.go | 4 | ||||
-rw-r--r-- | routers/user/home.go | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 6a713f9061..afe64c731f 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -286,6 +286,9 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB assigneeID = 0 // Reset ID to prevent unexpected selection of assignee. } + ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = + issue_service.GetRefEndNamesAndURLs(issues, ctx.Repo.RepoLink) + ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 { counts, ok := approvalCounts[issueID] if !ok || len(counts) == 0 { @@ -1127,6 +1130,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin) ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons + ctx.Data["RefEndName"] = git.RefEndName(issue.Ref) ctx.HTML(200, tplIssueView) } diff --git a/routers/user/home.go b/routers/user/home.go index 199694f236..2fc0c60aad 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" "github.com/keybase/go-crypto/openpgp" @@ -624,6 +625,9 @@ func Issues(ctx *context.Context) { totalIssues = int(allIssueStats.ClosedCount) } + ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = + issue_service.GetRefEndNamesAndURLs(issues, ctx.Query("RepoLink")) + ctx.Data["Issues"] = issues ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 { counts, ok := approvalCounts[issueID] |