Skip to content

Commit 8ec7400

Browse files
Redirect issue if repo has configured external tracker.
1 parent e43de0d commit 8ec7400

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docs/content/doc/usage/linked-references.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ In the examples, `User1/Repo1` refers to the repository where the reference is u
156156
| `User1/Repo1!1234` | yes | N/A | A link to _PR_ 1234 for `User1/Repo1` |
157157
| `UserZ/RepoZ#1234` | N/A | no | A link to issue/pull 1234 in `UserZ/RepoZ` |
158158
| `UserZ/RepoZ!1234` | N/A | no | A link to issue/pull 1234 in `UserZ/RepoZ` |
159-
| _Not supported_ | N/A | yes | A link to _external issue_ 1234 for `UserZ/RepoZ` |
159+
| `UserZ/RepoZ#1234` | N/A | yes | A link to _external issue_ 1234 for `UserZ/RepoZ` |
160160
| `UserZ/RepoZ!1234` | N/A | yes | A link to _PR_ 1234 for `UserZ/RepoZ` |
161161
| **Alphanumeric issue IDs:** | - | - | - |
162162
| `AAA-1234` | yes | N/A | A link to _external issue_ `AAA-1234` for `User1/Repo1` |

routers/repo/issue.go

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/git"
2222
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
2323
"code.gitea.io/gitea/modules/log"
24+
"code.gitea.io/gitea/modules/markup"
2425
"code.gitea.io/gitea/modules/markup/markdown"
2526
"code.gitea.io/gitea/modules/notification"
2627
"code.gitea.io/gitea/modules/setting"
@@ -605,6 +606,15 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu
605606

606607
// ViewIssue render issue view page
607608
func ViewIssue(ctx *context.Context) {
609+
if extIssueUnit, _ := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker); extIssueUnit != nil {
610+
if extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == markup.IssueNameStyleNumeric {
611+
metas := ctx.Repo.Repository.ComposeMetas()
612+
metas["index"] = ctx.Params(":index")
613+
ctx.Redirect(com.Expand(extIssueUnit.ExternalTrackerConfig().ExternalTrackerFormat, metas))
614+
return
615+
}
616+
}
617+
608618
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
609619
if err != nil {
610620
if models.IsErrIssueNotExist(err) {

0 commit comments

Comments
 (0)