Skip to content

Commit a8f98fd

Browse files
GiteaBotkatsusan
andauthored
fix trailing comma not matched in the case of alphanumeric issue (#32945) (#32959)
Backport #32945 by @katsusan Fix #32428. Patch the regex to match `,`besides `.` `"` `'` `:` and space. Co-authored-by: katsu <[email protected]>
1 parent c442c68 commit a8f98fd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/references/references.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
// issueNumericPattern matches string that references to a numeric issue, e.g. #1287
3333
issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\")([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$)`)
3434
// issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
35-
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\')`)
35+
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\'|,)`)
3636
// crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
3737
// e.g. org/repo#12345
3838
crossReferenceIssueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+[#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)

modules/references/references_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ func TestRegExp_issueAlphanumericPattern(t *testing.T) {
463463
"ABC-123:",
464464
"\"ABC-123\"",
465465
"'ABC-123'",
466+
"ABC-123, unknown PR",
466467
}
467468
falseTestCases := []string{
468469
"RC-08",

0 commit comments

Comments
 (0)