mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-20 11:43:40 +09:00
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:
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user