Skip to content

Commit

Permalink
fix: if ! and BREAKING CHANGE were used, notes would populate twice (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 5, 2019
1 parent 2b8f1cd commit 63d8cbe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { breakingHeaderPattern } = require('./parser-opts')()

module.exports = (commit) => {
const match = commit.header.match(breakingHeaderPattern)
if (match) {
if (match && commit.notes.length === 0) {
const noteText = match[3] // the description of the change.
commit.notes.push({
text: noteText
Expand Down
20 changes: 18 additions & 2 deletions packages/conventional-changelog-conventionalcommits/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ betterThanBefore.setups([
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')

gitDummyCommit(['build: first build setup', 'BREAKING CHANGE: New build system.'])
gitDummyCommit(['build!: first build setup', 'BREAKING CHANGE: New build system.'])
gitDummyCommit(['ci(travis): add TravisCI pipeline', 'BREAKING CHANGE: Continuously integrated.'])
gitDummyCommit(['Feat: amazing new module', 'BREAKING CHANGE: Not backward compatible.'])
gitDummyCommit(['Fix(compile): avoid a bug', 'BREAKING CHANGE: The Change is huge.'])
Expand Down Expand Up @@ -113,6 +113,22 @@ describe('conventionalcommits.org preset', function () {
}))
})

it('should not list breaking change twice if ! is used', function (done) {
preparing(1)

conventionalChangelogCore({
config: preset
})
.on('error', function (err) {
done(err)
})
.pipe(through(function (chunk) {
chunk = chunk.toString()
expect(chunk).to.not.match(/\* first build setup\r?\n/)
done()
}))
})

it('should allow alternative "types" configuration to be provided', function (done) {
preparing(1)
conventionalChangelogCore({
Expand Down Expand Up @@ -432,7 +448,7 @@ describe('conventionalcommits.org preset', function () {
})
.pipe(through(function (chunk) {
chunk = chunk.toString()
expect(chunk).to.match(/incredible new flag FIXES: #33\n/)
expect(chunk).to.match(/incredible new flag FIXES: #33\r?\n/)
done()
}))
})
Expand Down

0 comments on commit 63d8cbe

Please sign in to comment.