Skip to content

Commit

Permalink
fix(commit): don't try to process and add changelog if skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
georgiee committed Mar 28, 2019
1 parent aad6a61 commit 4cb7c07
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/lifecycles/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,37 @@ module.exports = function (args, newVersion) {

function execCommit (args, newVersion) {
var msg = 'committing %s'
var paths = [args.infile]
var verify = args.verify === false || args.n ? '--no-verify ' : ''
var paths = []
var toAdd = ''

// only start with a pre-populated paths list when CHANGELOG processing is not skipped
if (!args.skip.changelog) {
paths = [args.infile]
toAdd += args.infile
}

var verify = args.verify === false || args.n ? '--no-verify ' : ''
// commit any of the config files that we've updated
// the version # for.
Object.keys(bump.getUpdatedConfigs()).forEach(function (p) {
if (bump.getUpdatedConfigs()[p]) {
msg += ' and %s'
paths.unshift(path.basename(p))
toAdd += ' ' + path.relative(process.cwd(), p)

// account for multiple files in the output message
if (paths.length > 1) {
msg += ' and %s'
}
}
})
checkpoint(args, msg, paths)
return runExec(args, 'git add' + toAdd + ' ' + args.infile)

if (args.skip.changelog && args.skip.bump && toAdd.length === 0) {
return Promise.resolve()
}

return runExec(args, 'git add ' + toAdd)
.then(() => {
return runExec(args, 'git commit ' + verify + (args.sign ? '-S ' : '') + (args.commitAll ? '' : (args.infile + toAdd)) + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
return runExec(args, 'git commit ' + verify + (args.sign ? '-S ' : '') + (args.commitAll ? '' : (toAdd)) + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
})
}
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,16 @@ describe('standard-version', function () {
})

describe('skip', () => {
it('can skip changelog generation when a changelog file is not present', function () {
writePackageJson('1.0.0')

commit('feat: first commit')
return execCliAsync('--skip.changelog true')
.then(function () {
getPackageVersion().should.equal('1.1.0')
})
})

it('allows bump and changelog generation to be skipped', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
Expand Down

0 comments on commit 4cb7c07

Please sign in to comment.