From cb9c0eb8ca2d29c9c1860535e1f6e2aaba011ced Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 7 Aug 2024 03:19:12 +0200 Subject: [PATCH] [BUG] Render references to cross-repo issues with external issues - If you have the external issue setting enabled, any reference would have been rendered as an external issue, however this shouldn't be happening to references that refer to issues in other repositories. - Unit test added. (cherry picked from commit 05e163aaf39307f1fa4e91c687633eb05d2a8f31) --- modules/markup/html.go | 2 +- modules/markup/html_internal_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index 4c73b6d796..cfb1b418ef 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -880,7 +880,7 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) { var link *html.Node reftext := node.Data[ref.RefLocation.Start:ref.RefLocation.End] - if hasExtTrackFormat && !ref.IsPull { + if hasExtTrackFormat && !ref.IsPull && ref.Owner == "" { ctx.Metas["index"] = ref.Issue res, err := vars.Expand(ctx.Metas["format"], ctx.Metas) diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go index 5319ef03a4..0ae57efba9 100644 --- a/modules/markup/html_internal_test.go +++ b/modules/markup/html_internal_test.go @@ -342,6 +342,22 @@ func TestRender_AutoLink(t *testing.T) { test(tmp, "d8a994ef24 (diff-2)") } +func TestRender_IssueIndexPatternRef(t *testing.T) { + setting.AppURL = TestAppURL + + test := func(input, expected string) { + var buf strings.Builder + err := postProcess(&RenderContext{ + Ctx: git.DefaultContext, + Metas: numericMetas, + }, []processor{issueIndexPatternProcessor}, strings.NewReader(input), &buf) + require.NoError(t, err) + assert.Equal(t, expected, buf.String(), "input=%q", input) + } + + test("alan-turin/Enigma-cryptanalysis#1", `alan-turin/Enigma-cryptanalysis#1`) +} + func TestRender_FullIssueURLs(t *testing.T) { setting.AppURL = TestAppURL