-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added support for commitAll option in CLI #121
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
"firstRelease": false, | ||
"sign": false, | ||
"noVerify": false, | ||
"commitAll": false, | ||
"silent": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ function outputChangelog (argv, cb) { | |
|
||
function handledExec (argv, cmd, errorCb, successCb) { | ||
// Exec given cmd and handle possible errors | ||
|
||
exec(cmd, function (err, stdout, stderr) { | ||
// If exec returns content in stderr, but no error, print it as a warning | ||
// If exec returns an error, print it and exit with return code 1 | ||
|
@@ -103,7 +104,7 @@ function commit (argv, newVersion, cb) { | |
checkpoint(argv, msg, args) | ||
|
||
handledExec(argv, 'git add package.json ' + argv.infile, cb, function () { | ||
handledExec(argv, 'git commit ' + verify + (argv.sign ? '-S ' : '') + 'package.json ' + argv.infile + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', cb, function () { | ||
handledExec(argv, 'git commit ' + verify + (argv.sign ? '-S ' : '') + (argv.commitAll ? '' : ('package.json ' + argv.infile)) + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', cb, function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is a bit messy. I'd like to use a variable. But doesn't have to be in this PR :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can refactor this in a separate PR. |
||
cb() | ||
}) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,29 @@ describe('cli', function () { | |
content.should.match(/1\.0\.1/) | ||
content.should.not.match(/legacy header format/) | ||
}) | ||
|
||
it('commits all staged files', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the test, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks :) |
||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
|
||
commit('feat: first commit') | ||
shell.exec('git tag -a v1.0.0 -m "my awesome first release"') | ||
commit('fix: patch release') | ||
|
||
fs.writeFileSync('STUFF.md', 'stuff\n', 'utf-8') | ||
|
||
shell.exec('git add STUFF.md') | ||
|
||
execCli('--commit-all').code.should.equal(0) | ||
|
||
var content = fs.readFileSync('CHANGELOG.md', 'utf-8') | ||
var status = shell.exec('git status') | ||
|
||
status.should.match(/On branch master\nnothing to commit, working directory clean\n/) | ||
status.should.not.match(/STUFF.md/) | ||
|
||
content.should.match(/1\.0\.1/) | ||
content.should.not.match(/legacy header format/) | ||
}) | ||
}) | ||
|
||
describe('with mocked git', function () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems a bit unnecessary to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wasn't intentional. I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I readded the whitespace, not sure why but it's not showing up in the diff here.