mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-16 12:05:30 +09:00
Backport #39436 by @breken-ai The `org` render meta is lower-cased (`Repository.composeCommonMetas` sets `metas["org"] = strings.ToLower(repo.OwnerName)`), but `mentionProcessor` compares it with the org part of the mention exactly as typed, while the team part is lower-cased before its lookup. So in a repository of the org `MyOrg`, `@MyOrg/developers` stays plain text, although `ResolveIssueMentionsByVisibility` lower-cases the name and still notifies that team. This compares the org part case-insensitively and adds a render test for team mentions. The code is the same on `release/v1.27`, so it could be backported. ### Verification - `go test ./modules/markup/ -run TestRender_TeamMention -count=1`: the `@Org1/Developers` case renders as plain text on current main and as the team link with this change; `go test ./modules/markup/...` passes. - `golangci-lint run ./modules/markup/` (v2.13.2): 0 issues. ### AI assistance This contribution was prepared with AI assistance. The behavior, the metas and mention-resolution code paths, the patch and the test were reviewed manually. > Built by breken, your AI support engineer - breken.ai - this one's on us. Co-authored-by: breken <support@brekfuz.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
3 files changed
+24
-7
No files matched your search
@@ -605,3 +605,18 @@ func TestIssue18471(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `<a href="`+markup.TestAppURL+`org/repo/compare/783b039...da951ce" class="compare"><code>783b039...da951ce</code></a>`, res.String())
|
||||
}
|
||||
|
||||
func TestRender_TeamMention(t *testing.T) {
|
||||
// the "org" meta is lower-cased, see Repository.composeCommonMetas
|
||||
metas := map[string]string{"user": "Org1", "repo": "repo1", "org": "org1", "teams": ",developers,"}
|
||||
test := func(input, expected string) {
|
||||
rctx := markup.NewTestRenderContext(markup.TestAppURL, metas).WithRelativePath("a.md")
|
||||
buffer, err := testRenderString(rctx, input)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
||||
}
|
||||
test("@org1/developers", `<p><a href="/org/org1/teams/developers" rel="nofollow">@org1/developers</a></p>`)
|
||||
test("@Org1/Developers", `<p><a href="/org/Org1/teams/Developers" rel="nofollow">@Org1/Developers</a></p>`)
|
||||
test("@org2/developers", `<p>@org2/developers</p>`)
|
||||
test("@org1/testers", `<p>@org1/testers</p>`)
|
||||
}
|
||||
Reference in new issue
Block a user