diff options
author | David Svantesson <david.svantesson@qrtech.se> | 2019-12-07 05:21:18 +0100 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-12-06 23:21:18 -0500 |
commit | 9cb418e623a137fb03f6540517e6e5f4ff6e92cc (patch) | |
tree | 6bd9af2a628961647f02e86a9564b5b3c2e81875 /routers/repo/issue.go | |
parent | 82e0383d2104f454af5b3e0e768f0497113f3b13 (diff) | |
download | gitea-9cb418e623a137fb03f6540517e6e5f4ff6e92cc.tar.gz gitea-9cb418e623a137fb03f6540517e6e5f4ff6e92cc.zip |
Redirect issue if repo has configured external tracker. (#9247)
* Redirect issue if repo has configured external tracker.
* Handle error
* Add tests for redirect
* Fix test consistency
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 66e87e714f..c79ea02e86 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/git" issue_indexer "code.gitea.io/gitea/modules/indexer/issues" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" @@ -606,6 +607,19 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu // ViewIssue render issue view page func ViewIssue(ctx *context.Context) { + extIssueUnit, err := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker) + if err == nil && extIssueUnit != nil { + if extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == markup.IssueNameStyleNumeric || extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == "" { + metas := ctx.Repo.Repository.ComposeMetas() + metas["index"] = ctx.Params(":index") + ctx.Redirect(com.Expand(extIssueUnit.ExternalTrackerConfig().ExternalTrackerFormat, metas)) + return + } + } else if err != nil && !models.IsErrUnitTypeNotExist(err) { + ctx.ServerError("GetUnit", err) + return + } + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { |