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
+16 -2
View File
@@ -378,9 +378,23 @@ func FindRenderizableReferenceRegexp(content string, pattern *regexp.Regexp) *Re
return nil
}
action, location := findActionKeywords([]byte(content), match[2])
// The external tracker pattern can use alternatives with separate capture
// groups. Pick the first group that participated in this match instead of
// assuming the first group always did.
issueStart, issueEnd := -1, -1
for i := 2; i+1 < len(match); i += 2 {
if match[i] >= 0 {
issueStart, issueEnd = match[i], match[i+1]
break
}
}
if issueStart < 0 {
return nil
}
action, location := findActionKeywords([]byte(content), issueStart)
return &RenderizableReference{
Issue: content[match[2]:match[3]],
Issue: content[issueStart:issueEnd],
RefLocation: &RefSpan{Start: match[0], End: match[1]},
Action: action,
ActionLocation: location,