summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Warren <earl-warren@noreply.codeberg.org>2024-08-07 08:32:59 +0200
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-08-07 08:32:59 +0200
commit9b1eb835c22ae80594cf5aaad84d052cd206e96c (patch)
treee6a5798b5a776fdd38cd7926416fc7536b84aa42
parentMerge pull request '[v8.0/forgejo] [UI] Do not include trailing EOL character... (diff)
parent[BUG] Render references to cross-repo issues with external issues (diff)
downloadforgejo-9b1eb835c22ae80594cf5aaad84d052cd206e96c.tar.xz
forgejo-9b1eb835c22ae80594cf5aaad84d052cd206e96c.zip
Merge pull request '[v8.0/forgejo] [BUG] Render references to cross-repo issues with external issues' (#4864) from bp-v8.0/forgejo-05e163a into v8.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4864 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
-rw-r--r--modules/markup/html.go2
-rw-r--r--modules/markup/html_internal_test.go16
2 files changed, 17 insertions, 1 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index b5c0e405ae..b5aadb2ad5 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -867,7 +867,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 17eff59d56..adc93adb2f 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, "<a href=\""+tmp+"\" class=\"commit\"><code class=\"nohighlight\">d8a994ef24 (diff-2)</code></a>")
}
+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", `<a href="/alan-turin/enigma-cryptanalysis/issues/1" class="ref-issue">alan-turin/Enigma-cryptanalysis#1</a>`)
+}
+
func TestRender_FullIssueURLs(t *testing.T) {
setting.AppURL = TestAppURL