fix: use correct format for pull request references (#8890)

Use `!` instead of `#` for references in the sidebar of pull requests. This is useful when the repository uses a external issue tracker to avoid it being redirected to the external issue tracker.

Resolves forgejo/forgejo#8713

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8890
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: jank1619 <jank1619@noreply.codeberg.org>
Co-committed-by: jank1619 <jank1619@noreply.codeberg.org>
This commit is contained in:
jank1619 2025-08-15 14:18:00 +02:00 committed by Gusted
commit 011e876f5c
2 changed files with 22 additions and 1 deletions

View file

@ -1,5 +1,10 @@
<div class="ui reference">
{{$issueReferenceLink := printf "%s#%d" .Issue.Repo.FullName .Issue.Index}}
{{$issueReferenceLink := ""}}
{{if .Issue.IsPull}}
{{$issueReferenceLink = printf "%s!%d" .Issue.Repo.FullName .Issue.Index}}
{{else}}
{{$issueReferenceLink = printf "%s#%d" .Issue.Repo.FullName .Issue.Index}}
{{end}}
<span class="text">
<strong>
{{ctx.Locale.Tr "discussion.sidebar.reference"}}

View file

@ -349,3 +349,19 @@ test.describe('Dependency dropdown', () => {
await expect(depsBlock).toContainText('No dependencies set');
});
});
test('Issue: Reference', async ({page}) => {
let response = await page.goto('/user2/repo1/pulls/5');
expect(response?.status()).toBe(200);
await expect(page.locator('.ui.reference .truncate')).toContainText(
'user2/repo1!5',
);
response = await page.goto('/user2/repo1/issues/1');
expect(response?.status()).toBe(200);
await expect(page.locator('.ui.reference .truncate')).toContainText(
'user2/repo1#1',
);
});