Skip to content

Commit 8f02736

Browse files
nexdrewbcoe
authored andcommitted
fix: format the annotated tag message (#28)
1 parent d20f36e commit 8f02736

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function formatCommitMessage (msg, newVersion) {
124124

125125
function tag (newVersion, argv) {
126126
checkpoint('tagging release %s', [newVersion])
127-
exec('git tag -a v' + newVersion + ' -m "' + argv.message + '"', function (err, stdout, stderr) {
127+
exec('git tag -a v' + newVersion + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) {
128128
var errMessage = null
129129
if (err) errMessage = err.message
130130
if (stderr) errMessage = stderr

test.js

+17
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,21 @@ describe('cli', function () {
9393
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
9494
content.should.match(/this is my fairly long commit message which is testing whether or not we allow for long commit messages/)
9595
})
96+
97+
it('formats the commit and tag messages appropriately', function () {
98+
fs.writeFileSync('package.json', JSON.stringify({
99+
version: '1.0.0'
100+
}), 'utf-8')
101+
102+
commit('feat: first commit')
103+
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
104+
commit('feat: new feature!')
105+
106+
shell.exec(cliPath).code.should.equal(0)
107+
108+
// check last commit message
109+
shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\)\: 1\.1\.0/)
110+
// check annotated tag message
111+
shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\)\: 1\.1\.0/)
112+
})
96113
})

0 commit comments

Comments
 (0)