-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commit): the bang (!) indicates a breaking change
A commit is considered a breaking (major) change when a bang char is encountered prior to the colon + subject and no prior commit notes are found. Ref: gh-5
- Loading branch information
1 parent
32e43d8
commit 034b30d
Showing
7 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
BREAKING_HEADER_REGEX: /^(\w*)(?:\((.*)\))?!: (.*)$/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
const {test, threw} = require('tap') | ||
const constants = require('../../lib/constants.js') | ||
|
||
test('constants', async (t) => { | ||
t.strictEqual(Object.keys(constants).length, 1, 'expected number of constants') | ||
|
||
t.match(constants, { | ||
BREAKING_HEADER_REGEX: RegExp | ||
}) | ||
|
||
t.test('BREAKING_HEADER_REGEX', async (t) => { | ||
const {BREAKING_HEADER_REGEX} = constants | ||
t.test('breaking change w/o scope', async (t) => { | ||
const match = BREAKING_HEADER_REGEX.exec('test!: this is breaking') | ||
const [_, type, scope, subject] = match | ||
t.strictEqual(type, 'test', 'commit type') | ||
t.strictEqual(scope, undefined, 'commit scope') | ||
t.strictEqual(subject, 'this is breaking', 'commit subject') | ||
}) | ||
t.test('breaking change w/ scope', async (t) => { | ||
const match = BREAKING_HEADER_REGEX.exec('doc(readme)!: this is breaking') | ||
const [_, type, scope, subject] = match | ||
t.strictEqual(type, 'doc', 'commit type') | ||
t.strictEqual(scope, 'readme', 'commit scope') | ||
t.strictEqual(subject, 'this is breaking', 'commit subject') | ||
}) | ||
t.test('non-breaking change', async (t) => { | ||
const match = BREAKING_HEADER_REGEX.exec('doc(readme): this is breaking') | ||
t.notOk(match, 'no match found') | ||
}) | ||
}) | ||
}).catch(threw) |