Skip to content

Commit 292b0d5

Browse files
committed
Don't check JIRA ID unless branch has one
Before this change, we complained about a leading JIRA issue ID even when the branch name didn't contain any JIRA prefix.
1 parent 5c86a05 commit 292b0d5

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/jira.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ function getJiraBranchIdMismatchDiagnostic(
6767
}
6868

6969
const branchIssueId = utils.getJiraIssueIdFromBranchName(gitBranch);
70+
if (!branchIssueId) {
71+
// No issue ID in the branch name, never mind
72+
return [];
73+
}
7074
if (docIssueId.id.toUpperCase() === branchIssueId) {
7175
// Text and branch match, done!
7276
return [];

src/test/suite/jira.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ suite("JIRA Prefix Warnings", () => {
6262
[expected]
6363
);
6464
});
65+
66+
test("JIRA-123: No branch issue ID", () => {
67+
assert.deepStrictEqual(
68+
jira._private.getJiraBranchIdMismatchDiagnostic(
69+
"holly-molly-polly",
70+
"JIRA-123: No branch issue ID"
71+
),
72+
[]
73+
);
74+
});
6575
});
6676

6777
suite("Quick Fix", () => {
@@ -141,6 +151,17 @@ suite("Quick Fix", () => {
141151
]);
142152
});
143153

154+
test("[JIRA-123] No branch issue ID", async () => {
155+
const doc = await createTextDocument(["[JIRA-123] No branch issue ID"]);
156+
const actual = jira._private.createBranchIssueIdFix(
157+
"tom-dick-and-harry",
158+
doc,
159+
utils.createRange(0, 5, 5)
160+
);
161+
162+
assert.deepEqual(actual, []);
163+
});
164+
144165
test("[JIRA-234] Already matching the branch issue ID", async () => {
145166
const doc = await createTextDocument([
146167
"[JIRA-234] Should match branch issue ID",

0 commit comments

Comments
 (0)