enhance: improve issue-pattern capture groups and support both internal&external trackers enabled (#39354)

* Fix #39351
* Fix #17621
* Fix #34881

By the way, fix error handling bugs in `updateRepoUnits`

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
breken
2026-09-18 08:53:45 -07:00
committed by GitHub
co-authored by wxiaoguang
parent 85eaf5c71c
commit b27e7d0289
13 changed files with 145 additions and 112 deletions
+15 -9
View File
@@ -39,7 +39,7 @@ func link(href, class, contents string) string {
}
var numericMetas = map[string]string{
"format": "https://someurl.com/{user}/{repo}/{index}",
"externalTrackerLinkFormat": "https://someurl.com/{user}/{repo}/{index}",
"user": "someUser",
"repo": "someRepo",
"style": IssueNameStyleNumeric,
@@ -47,7 +47,7 @@ var numericMetas = map[string]string{
}
var alphanumericMetas = map[string]string{
"format": "https://someurl.com/{user}/{repo}/{index}",
"externalTrackerLinkFormat": "https://someurl.com/{user}/{repo}/{index}",
"user": "someUser",
"repo": "someRepo",
"style": IssueNameStyleAlphanumeric,
@@ -55,10 +55,10 @@ var alphanumericMetas = map[string]string{
}
var regexpMetas = map[string]string{
"format": "https://someurl.com/{user}/{repo}/{index}",
"user": "someUser",
"repo": "someRepo",
"style": IssueNameStyleRegexp,
"externalTrackerLinkFormat": "https://someurl.com/{user}/{repo}/{index}",
"user": "someUser",
"repo": "someRepo",
"style": IssueNameStyleRegexp,
}
// these values should match the TestOrgRepo const above
@@ -219,23 +219,29 @@ func TestRender_IssueIndexPattern5(t *testing.T) {
}
test("abc ISSUE-123 def", "abc %s def",
"ISSUE-(\\d+)",
`ISSUE-(\d+)`,
[]string{"123"},
[]string{"ISSUE-123"},
)
test("abc (ISSUE 123) def", "abc %s def",
"\\(ISSUE (\\d+)\\)",
`\(ISSUE (\d+)\)`,
[]string{"123"},
[]string{"(ISSUE 123)"},
)
test("abc ISSUE-123 def", "abc %s def",
"(ISSUE-(\\d+))",
`(ISSUE-(\d+))`,
[]string{"ISSUE-123"},
[]string{"ISSUE-123"},
)
test("123456: TEST-123456", "%s %s",
`(\d+):|TEST-(\d+)`,
[]string{"123456", "123456"},
[]string{"123456:", "TEST-123456"},
)
testRenderIssueIndexPattern(t, "will not match", "will not match", NewTestRenderContext(regexpMetas))
}