aboutsummaryrefslogtreecommitdiffstats
path: root/modules/references
diff options
context:
space:
mode:
Diffstat (limited to 'modules/references')
-rw-r--r--modules/references/references.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/modules/references/references.go b/modules/references/references.go
index 630e621043..7f5086d093 100644
--- a/modules/references/references.go
+++ b/modules/references/references.go
@@ -351,6 +351,24 @@ func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *Rende
}
}
+// FindRenderizableReferenceRegexp returns the first regexp unvalidated references found in a string.
+func FindRenderizableReferenceRegexp(content string, pattern *regexp.Regexp) (bool, *RenderizableReference) {
+ match := pattern.FindStringSubmatchIndex(content)
+ if len(match) < 4 {
+ return false, nil
+ }
+
+ action, location := findActionKeywords([]byte(content), match[2])
+
+ return true, &RenderizableReference{
+ Issue: content[match[2]:match[3]],
+ RefLocation: &RefSpan{Start: match[0], End: match[1]},
+ Action: action,
+ ActionLocation: location,
+ IsPull: false,
+ }
+}
+
// FindRenderizableReferenceAlphanumeric returns the first alphanumeric unvalidated references found in a string.
func FindRenderizableReferenceAlphanumeric(content string) (bool, *RenderizableReference) {
match := issueAlphanumericPattern.FindStringSubmatchIndex(content)
@@ -547,7 +565,7 @@ func findActionKeywords(content []byte, start int) (XRefAction, *RefSpan) {
}
// IsXrefActionable returns true if the xref action is actionable (i.e. produces a result when resolved)
-func IsXrefActionable(ref *RenderizableReference, extTracker, alphaNum bool) bool {
+func IsXrefActionable(ref *RenderizableReference, extTracker bool) bool {
if extTracker {
// External issues cannot be automatically closed
return false