Skip to content

Commit b22a352

Browse files
committed
Find undecorated JIRA prefix from subject line
1 parent 00c8e93 commit b22a352

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/test/suite/utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ suite("Utils", () => {
1616
id: "jira-123",
1717
});
1818

19+
assert.deepStrictEqual(utils.findJiraIssueId("jira-123 Hello"), {
20+
startIndex: 0,
21+
firstIndexAfter: 9,
22+
id: "jira-123",
23+
});
24+
1925
assert.deepStrictEqual(utils.findJiraIssueId("Hello"), {
2026
startIndex: 0,
2127
firstIndexAfter: 0,

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import * as vscode from "vscode";
66

7+
/** JIRA-123 */
8+
const jiraPrefixUndecorated = /^()([a-zA-Z]{2,}-[0-9]+) +/;
9+
710
/** JIRA-123: */
811
const jiraPrefixWithColon = /^()([a-zA-Z]{2,}-[0-9]+): +/;
912

@@ -56,7 +59,10 @@ export function createDiagnostic(
5659
}
5760

5861
export function findJiraIssueId(firstLine: string): JiraIssueIdPrefix {
59-
let match = firstLine.match(jiraPrefixWithColon);
62+
let match = firstLine.match(jiraPrefixUndecorated);
63+
if (!match) {
64+
match = firstLine.match(jiraPrefixWithColon);
65+
}
6066
if (!match) {
6167
match = firstLine.match(jiraPrefixWithBrackets);
6268
}

0 commit comments

Comments
 (0)