Skip to content

Commit 3181cb7

Browse files
committed
Respect merge message structure for parsing item references
Signed-off-by: JustusBunsi <[email protected]>
1 parent a2df265 commit 3181cb7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/references/references.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
// mentionPattern matches all mentions in the form of "@user" or "@org/team"
3030
mentionPattern = regexp.MustCompile(`(?:\s|^|\(|\[)(@[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_]+\/?[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_][0-9a-zA-Z-_.]+\/?[0-9a-zA-Z-_.]+[0-9a-zA-Z-_])(?:\s|[:,;.?!]\s|[:,;.?!]?$|\)|\])`)
3131
// issueNumericPattern matches string that references to a numeric issue, e.g. #1287
32-
issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
32+
issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|Merge pull request \')([#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
3333
// issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
3434
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$))`)
3535
// crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository

modules/references/references_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ func TestFindAllIssueReferences(t *testing.T) {
197197
{200, "user3", "repo4", "200", false, XRefActionNone, &RefSpan{Start: 5, End: 20}, nil, ""},
198198
},
199199
},
200+
{
201+
"Merge pull request '#12345 My fix for a bug' (!1337) from feature-branch into main",
202+
[]testResult{
203+
{12345, "", "", "12345", false, XRefActionNone, &RefSpan{Start: 20, End: 26}, nil, ""},
204+
{1337, "", "", "1337", true, XRefActionNone, &RefSpan{Start: 46, End: 51}, nil, ""},
205+
},
206+
},
200207
{
201208
"Which abc. #9434 same as above",
202209
[]testResult{

0 commit comments

Comments
 (0)