Skip to content

Commit

Permalink
feat: camel case jira tag support (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpater authored Apr 12, 2022
1 parent 83ff02b commit 3bb49d8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = function(options) {
const maxHeaderWidth = getFromOptionsOrDefaults('maxHeaderWidth');

const branchName = execSync('git branch --show-current').toString().trim();
const jiraIssueRegex = /(?<jiraIssue>(?<!([A-Z0-9]{1,10})-?)[A-Z0-9]+-\d+)/;
const jiraIssueRegex = /(?<jiraIssue>(?<!([a-zA-Z0-9]{1,10})-?)[a-zA-Z0-9]+-\d+)/;
const matchResult = branchName.match(jiraIssueRegex);
const jiraIssue =
matchResult && matchResult.groups && matchResult.groups.jiraIssue;
Expand Down Expand Up @@ -122,7 +122,7 @@ module.exports = function(options) {
validate: function(jira) {
return (
(options.jiraOptional && !jira) ||
/^(?<!([A-Z0-9]{1,10})-?)[A-Z0-9]+-\d+$/.test(jira)
/^(?<!([a-zA-Z0-9]{1,10})-?)[a-zA-Z0-9]+-\d+$/.test(jira)
);
},
filter: function(jira) {
Expand Down
63 changes: 32 additions & 31 deletions engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var defaultOptions = defaults;
var type = 'func';
var scope = 'everything';
var customScope = 'custom scope';
var jira = 'DAZ-123';
var jira = 'dAz-123';
var jiraUpperCase = 'DAZ-123';
var subject = 'testing123';
const shortBody = 'a';
var longBody =
Expand Down Expand Up @@ -55,7 +56,7 @@ describe('commit message', function() {
jira,
subject
})
).to.equal(`${type}: ${jira} ${subject}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}`);
});
it('only header w/ scope', function() {
expect(
Expand All @@ -65,7 +66,7 @@ describe('commit message', function() {
jira,
subject
})
).to.equal(`${type}(${scope}): ${jira} ${subject}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}`);
});
it('header and body w/ out scope', function() {
expect(
Expand All @@ -75,7 +76,7 @@ describe('commit message', function() {
subject,
body
})
).to.equal(`${type}: ${jira} ${subject}\n\n${body}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}\n\n${body}`);
});
it('header and body w/ scope', function() {
expect(
Expand All @@ -86,7 +87,7 @@ describe('commit message', function() {
subject,
body
})
).to.equal(`${type}(${scope}): ${jira} ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${body}`);
});
it('header and body w/ custom scope', function() {
expect(
Expand All @@ -98,7 +99,7 @@ describe('commit message', function() {
subject,
body
})
).to.equal(`${type}(${customScope}): ${jira} ${subject}\n\n${body}`);
).to.equal(`${type}(${customScope}): ${jiraUpperCase} ${subject}\n\n${body}`);
});
it('header, body and issues w/ out scope', function() {
expect(
Expand All @@ -109,7 +110,7 @@ describe('commit message', function() {
body,
issues
})
).to.equal(`${type}: ${jira} ${subject}\n\n${body}\n\n${issues}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}\n\n${body}\n\n${issues}`);
});
it('header, body and issues w/ scope', function() {
expect(
Expand All @@ -121,7 +122,7 @@ describe('commit message', function() {
body,
issues
})
).to.equal(`${type}(${scope}): ${jira} ${subject}\n\n${body}\n\n${issues}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${body}\n\n${issues}`);
});
it('header, body and long issues w/ out scope', function() {
expect(
Expand All @@ -132,7 +133,7 @@ describe('commit message', function() {
body,
issues: longIssues
})
).to.equal(`${type}: ${jira} ${subject}\n\n${body}\n\n${longIssuesSplit}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}\n\n${body}\n\n${longIssuesSplit}`);
});
it('header, body and long issues w/ scope', function() {
expect(
Expand All @@ -145,7 +146,7 @@ describe('commit message', function() {
issues: longIssues
})
).to.equal(
`${type}(${scope}): ${jira} ${subject}\n\n${body}\n\n${longIssuesSplit}`
`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${body}\n\n${longIssuesSplit}`
);
});
it('header and long body w/ out scope', function() {
Expand All @@ -156,7 +157,7 @@ describe('commit message', function() {
subject,
body: longBody
})
).to.equal(`${type}: ${jira} ${subject}\n\n${longBodySplit}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}\n\n${longBodySplit}`);
});
it('header and long body w/ scope', function() {
expect(
Expand All @@ -167,7 +168,7 @@ describe('commit message', function() {
subject,
body: longBody
})
).to.equal(`${type}(${scope}): ${jira} ${subject}\n\n${longBodySplit}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${longBodySplit}`);
});
it('header, long body and issues w/ out scope', function() {
expect(
Expand All @@ -178,7 +179,7 @@ describe('commit message', function() {
body: longBody,
issues
})
).to.equal(`${type}: ${jira} ${subject}\n\n${longBodySplit}\n\n${issues}`);
).to.equal(`${type}: ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${issues}`);
});
it('header, long body and issues w/ scope', function() {
expect(
Expand All @@ -191,7 +192,7 @@ describe('commit message', function() {
issues
})
).to.equal(
`${type}(${scope}): ${jira} ${subject}\n\n${longBodySplit}\n\n${issues}`
`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${issues}`
);
});
it('header, long body and long issues w/ out scope', function() {
Expand All @@ -204,7 +205,7 @@ describe('commit message', function() {
issues: longIssues
})
).to.equal(
`${type}: ${jira} ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
`${type}: ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
);
});
it('header, long body and long issues w/ scope', function() {
Expand All @@ -218,7 +219,7 @@ describe('commit message', function() {
issues: longIssues
})
).to.equal(
`${type}(${scope}): ${jira} ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
);
});
it('header, long body, breaking change, and long issues w/ scope', function() {
Expand All @@ -233,7 +234,7 @@ describe('commit message', function() {
issues: longIssues
})
).to.equal(
`${type}(${scope}): ${jira} ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
);
});
it('header, long body, breaking change (with prefix entered), and long issues w/ scope', function() {
Expand All @@ -248,7 +249,7 @@ describe('commit message', function() {
issues: longIssues
})
).to.equal(
`${type}(${scope}): ${jira} ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
);
});
it('header, body, breaking change, and issues w/ scope; exclamation mark enabled', function() {
Expand All @@ -264,7 +265,7 @@ describe('commit message', function() {
},
{ ...defaultOptions, exclamationMark: true })
).to.equal(
`${type}(${scope})!: ${jira} ${subject}\n\n${body}\n\n${breakingChange}${breaking}\n\n${issues}`
`${type}(${scope})!: ${jiraUpperCase} ${subject}\n\n${body}\n\n${breakingChange}${breaking}\n\n${issues}`
);
});
it('header, body, breaking change, and issues w/o scope; exclamation mark enabled', function() {
Expand All @@ -279,7 +280,7 @@ describe('commit message', function() {
},
{ ...defaultOptions, exclamationMark: true })
).to.equal(
`${type}!: ${jira} ${subject}\n\n${body}\n\n${breakingChange}${breaking}\n\n${issues}`
`${type}!: ${jiraUpperCase} ${subject}\n\n${body}\n\n${breakingChange}${breaking}\n\n${issues}`
);
});
it('skip jira task when optional', function() {
Expand Down Expand Up @@ -307,7 +308,7 @@ describe('commit message', function() {
},
{ jiraLocation: 'unknown-location' }
)
).to.equal(`${type}(${scope}): ${jira} ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${body}`);
});
it('pre-type jiraLocation', function() {
expect(
Expand All @@ -321,7 +322,7 @@ describe('commit message', function() {
},
{ jiraLocation: 'pre-type' }
)
).to.equal(`${jira} ${type}(${scope}): ${subject}\n\n${body}`);
).to.equal(`${jiraUpperCase} ${type}(${scope}): ${subject}\n\n${body}`);
});
it('pre-description jiraLocation', function() {
expect(
Expand All @@ -335,7 +336,7 @@ describe('commit message', function() {
},
{ jiraLocation: 'pre-description' }
)
).to.equal(`${type}(${scope}): ${jira} ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase} ${subject}\n\n${body}`);
});
it('post-description jiraLocation', function() {
expect(
Expand All @@ -349,7 +350,7 @@ describe('commit message', function() {
},
{ jiraLocation: 'post-description' }
)
).to.equal(`${type}(${scope}): ${subject} ${jira} \n\n${body}`);
).to.equal(`${type}(${scope}): ${subject} ${jiraUpperCase} \n\n${body}`);
});
it('post-body jiraLocation with body', function() {
expect(
Expand All @@ -363,7 +364,7 @@ describe('commit message', function() {
},
{ ...defaultOptions, jiraLocation: 'post-body' }
)
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jira}`);
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}`);
});
it('post-body jiraLocation no body', function() {
expect(
Expand All @@ -377,7 +378,7 @@ describe('commit message', function() {
},
{ ...defaultOptions, jiraLocation: 'post-body' }
)
).to.equal(`${type}(${scope}): ${subject}\n\n${jira}`);
).to.equal(`${type}(${scope}): ${subject}\n\n${jiraUpperCase}`);
});
it('post-body jiraLocation with body and footer', function() {
var footer = `${breakingChange}${breaking}`;
Expand All @@ -393,7 +394,7 @@ describe('commit message', function() {
},
{ ...defaultOptions, jiraLocation: 'post-body' }
)
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jira}\n\n${breakingChange}${breaking}`);
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}\n\n${breakingChange}${breaking}`);
});
it('jiraPrepend decorator', function() {
expect(
Expand All @@ -407,7 +408,7 @@ describe('commit message', function() {
},
{ jiraPrepend: '-' }
)
).to.equal(`${type}(${scope}): -${jira} ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): -${jiraUpperCase} ${subject}\n\n${body}`);
});
it('jiraAppend decorator', function() {
expect(
Expand All @@ -421,7 +422,7 @@ describe('commit message', function() {
},
{ jiraAppend: '+' }
)
).to.equal(`${type}(${scope}): ${jira}+ ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): ${jiraUpperCase}+ ${subject}\n\n${body}`);
});
it('jiraPrepend and jiraAppend decorators', function() {
expect(
Expand All @@ -438,7 +439,7 @@ describe('commit message', function() {
jiraPrepend: '['
}
)
).to.equal(`${type}(${scope}): [${jira}] ${subject}\n\n${body}`);
).to.equal(`${type}(${scope}): [${jiraUpperCase}] ${subject}\n\n${body}`);
});
it('jiraLocation, jiraPrepend, jiraAppend decorators', function() {
expect(
Expand All @@ -456,7 +457,7 @@ describe('commit message', function() {
jiraLocation: 'pre-type'
}
)
).to.equal(`[${jira}] ${type}(${scope}): ${subject}\n\n${body}`);
).to.equal(`[${jiraUpperCase}] ${type}(${scope}): ${subject}\n\n${body}`);
});
});

Expand Down

0 comments on commit 3bb49d8

Please sign in to comment.