mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 21:27:13 +00:00
Merge pull request '[BUG] Render references to cross-repo issues with external issues' (#4860) from gusted/forgejo-ref-on-external into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4860 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
1ddf44edd6
|
@ -867,7 +867,7 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
|
||||||
|
|
||||||
var link *html.Node
|
var link *html.Node
|
||||||
reftext := node.Data[ref.RefLocation.Start:ref.RefLocation.End]
|
reftext := node.Data[ref.RefLocation.Start:ref.RefLocation.End]
|
||||||
if hasExtTrackFormat && !ref.IsPull {
|
if hasExtTrackFormat && !ref.IsPull && ref.Owner == "" {
|
||||||
ctx.Metas["index"] = ref.Issue
|
ctx.Metas["index"] = ref.Issue
|
||||||
|
|
||||||
res, err := vars.Expand(ctx.Metas["format"], ctx.Metas)
|
res, err := vars.Expand(ctx.Metas["format"], ctx.Metas)
|
||||||
|
|
|
@ -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>")
|
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) {
|
func TestRender_FullIssueURLs(t *testing.T) {
|
||||||
setting.AppURL = TestAppURL
|
setting.AppURL = TestAppURL
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue