Skip to content

Commit

Permalink
fix: support BREAKING-CHANGE alongside BREAKING CHANGE (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandeaual committed Dec 29, 2021
1 parent b2245a7 commit e6f44ad
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Expand Up @@ -10,7 +10,7 @@ module.exports = function (config) {
'scope',
'subject'
],
noteKeywords: ['BREAKING CHANGE'],
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
revertCorrespondence: ['header', 'hash'],
issuePrefixes: config.issuePrefixes
Expand Down
3 changes: 2 additions & 1 deletion packages/conventional-commits-parser/README.md
Expand Up @@ -201,7 +201,8 @@ Used to define if `issuePrefixes` should be considered case sensitive.

##### noteKeywords

Type: `array` of `string` or `string` Default: `['BREAKING CHANGE']`
Type: `array` of `string` or `string` Default: `['BREAKING CHANGE',
'BREAKING-CHANGE']`

Keywords for important notes. This value is case **insensitive**. If it's a `string` it will be converted to an `array` separated by a comma.

Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-commits-parser/index.js
Expand Up @@ -21,7 +21,7 @@ function assignOpts (options) {
'resolved'
],
issuePrefixes: ['#'],
noteKeywords: ['BREAKING CHANGE'],
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
fieldPattern: /^-(.*?)-$/,
revertPattern: /^Revert\s"([\s\S]*)"\s*This reverts commit (\w*)\./,
revertCorrespondence: ['header', 'hash'],
Expand Down
4 changes: 2 additions & 2 deletions packages/conventional-commits-parser/test/parser.spec.js
Expand Up @@ -688,7 +688,7 @@ describe('parser', function () {
const text = expectedText +
'\n' +
'Closes #9462'
options.noteKeywords = ['BREAKING CHANGE']
options.noteKeywords = ['BREAKING CHANGE', 'BREAKING-CHANGE']
reg = regex(options)
const msg = parser(
'fix(core): report duplicate template bindings in templates\n' +
Expand All @@ -710,7 +710,7 @@ describe('parser', function () {
})

it('should not treat it as important notes if there are texts after `noteKeywords`', function () {
options.noteKeywords = ['BREAKING CHANGE']
options.noteKeywords = ['BREAKING CHANGE', 'BREAKING-CHANGE']
reg = regex(options)
const msg = parser(
'fix(core): report duplicate template bindings in templates\n' +
Expand Down
4 changes: 2 additions & 2 deletions packages/conventional-commits-parser/test/regex.spec.js
Expand Up @@ -20,7 +20,7 @@ describe('regex', function () {

it('should match notes with customized pattern', function () {
const reNotes = regex({
noteKeywords: ['BREAKING CHANGE'],
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
notesPattern: (noteKeywords) => new RegExp('^[\\s|*]*(' + noteKeywords + ')[:\\s]+(?:\\[.*\\] )(.*)', 'i')
}).notes
const notes = 'BREAKING CHANGE: [Do not match this prefix.] This is so important.'
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('regex', function () {

it('should not match if there is text after `noteKeywords`', function () {
const reNotes = regex({
noteKeywords: [' BREAKING CHANGE'],
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
issuePrefixes: ['#']
}).notes
const match = 'BREAKING CHANGES: Wow.'.match(reNotes)
Expand Down

0 comments on commit e6f44ad

Please sign in to comment.