diff --git a/index.js b/index.js index 5a18542b9..a0f6d93a2 100755 --- a/index.js +++ b/index.js @@ -124,7 +124,7 @@ function formatCommitMessage (msg, newVersion) { function tag (newVersion, argv) { checkpoint('tagging release %s', [newVersion]) - exec('git tag -a v' + newVersion + ' -m "' + argv.message + '"', function (err, stdout, stderr) { + exec('git tag -a v' + newVersion + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { var errMessage = null if (err) errMessage = err.message if (stderr) errMessage = stderr diff --git a/test.js b/test.js index e0ec09740..672c197aa 100644 --- a/test.js +++ b/test.js @@ -93,4 +93,21 @@ describe('cli', function () { var content = fs.readFileSync('CHANGELOG.md', 'utf-8') content.should.match(/this is my fairly long commit message which is testing whether or not we allow for long commit messages/) }) + + it('formats the commit and tag messages appropriately', function () { + fs.writeFileSync('package.json', JSON.stringify({ + version: '1.0.0' + }), 'utf-8') + + commit('feat: first commit') + shell.exec('git tag -a v1.0.0 -m "my awesome first release"') + commit('feat: new feature!') + + shell.exec(cliPath).code.should.equal(0) + + // check last commit message + shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\)\: 1\.1\.0/) + // check annotated tag message + shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\)\: 1\.1\.0/) + }) })