Skip to content

Commit

Permalink
feat(conventionalcommits): include Release-As commits in CHANGELOG (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Apr 30, 2021
1 parent 8076d46 commit 9a0b9a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/conventional-changelog-conventionalcommits/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ betterThanBefore.setups([
function () {
gitDummyCommit(['Revert \\"feat: default revert format\\"', 'This reverts commit 1234.'])
gitDummyCommit(['revert: feat: custom revert format', 'This reverts commit 5678.'])
},
function () {
gitDummyCommit([
'chore: release at different version',
'Release-As: v3.0.2'
])
}
])

Expand Down Expand Up @@ -593,4 +599,19 @@ describe('conventionalcommits.org preset', function () {
done()
}))
})
it('should include commits with "Release-As:" footer in CHANGELOG', function (done) {
preparing(11)

conventionalChangelogCore({
config: preset
})
.on('error', function (err) {
done(err)
})
.pipe(through(function (chunk) {
chunk = chunk.toString()
expect(chunk).to.match(/release at different version/)
done()
}))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const compareFunc = require('compare-func')
const Q = require('q')
const readFile = Q.denodeify(require('fs').readFile)
const resolve = require('path').resolve
const releaseAsRe = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i

/**
* Handlebar partials for various property substitutions based on commit context.
Expand Down Expand Up @@ -81,6 +82,13 @@ function getWriterOpts (config) {
// a '!' but no 'BREAKING CHANGE' in body:
addBangNotes(commit)

// Add an entry in the CHANGELOG if special Release-As footer
// is used:
if ((commit.footer && releaseAsRe.test(commit.footer)) ||
(commit.body && releaseAsRe.test(commit.body))) {
discard = false
}

commit.notes.forEach(note => {
note.title = 'BREAKING CHANGES'
discard = false
Expand Down

0 comments on commit 9a0b9a7

Please sign in to comment.