simple-git
Advanced tools
Comparing version 1.25.0 to 1.26.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "1.25.0", | ||
"version": "1.26.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -140,3 +140,3 @@ (function () { | ||
* | ||
* @param {string} message | ||
* @param {string|string[]} message | ||
* @param {string|string[]} [files] | ||
@@ -146,11 +146,23 @@ * @param {Function} [then] | ||
Git.prototype.commit = function (message, files, then) { | ||
var git = this; | ||
if (!then && typeof files === "function") { | ||
then = files; | ||
var handler = Git.trailingFunctionArgument(arguments); | ||
if (handler === files || !files) { | ||
files = []; | ||
} | ||
return this._run(['commit', '-m', message].concat([].concat(files || [])), function (err, data) { | ||
then && then(err, !err && require('./CommitSummary').parse(data)); | ||
var command = ['commit']; | ||
[].concat(message).forEach(function (message) { | ||
command.push('-m', message); | ||
}); | ||
if (handler !== files && files) { | ||
[].concat(files).forEach(function (file) { | ||
command.push(file); | ||
}); | ||
} | ||
return this._run(command, function (err, data) { | ||
handler && handler(err, !err && require('./CommitSummary').parse(data)); | ||
}); | ||
}; | ||
@@ -157,0 +169,0 @@ |
@@ -79,2 +79,22 @@ | ||
'commit with single file specified and multiple line commit': function (test) { | ||
git.commit(['some', 'message'], 'fileName.ext', function (err, commit) { | ||
test.equals('unitTests', commit.branch, 'Should be on unitTests branch'); | ||
test.equals('44de1ee', commit.commit, 'Should pick up commit hash'); | ||
test.equals(3, commit.summary.changes, 'Should pick up changes count'); | ||
test.equals(12, commit.summary.deletions, 'Should pick up deletions count'); | ||
test.equals(29, commit.summary.insertions, 'Should pick up insertions count'); | ||
test.same( | ||
["commit", "-m", "some", "-m" ,"message", "fileName.ext"], | ||
theCommandRun()); | ||
test.done(); | ||
}); | ||
closeWith('[unitTests 44de1ee] Add nodeunit test runner\n\ | ||
3 files changed, 29 insertions(+), 12 deletions(-)\n\ | ||
create mode 100644 src/index.js'); | ||
}, | ||
'commit with multiple files specified': function (test) { | ||
@@ -101,2 +121,23 @@ git.commit('some message', ['fileName.ext', 'anotherFile.ext'], function (err, commit) { | ||
'commit with multiple files specified and multiple line commit': function (test) { | ||
git.commit(['some', 'message'], ['fileName.ext', 'anotherFile.ext'], function (err, commit) { | ||
test.equals('branchNameInHere', commit.branch, 'Should pick up branch name'); | ||
test.equals('CommitHash', commit.commit, 'Should pick up commit hash'); | ||
test.equals(3, commit.summary.changes, 'Should pick up changes count'); | ||
test.equals(12, commit.summary.deletions, 'Should pick up deletions count'); | ||
test.equals(29, commit.summary.insertions, 'Should pick up insertions count'); | ||
test.same( | ||
["commit", "-m", "some", "-m" ,"message", "fileName.ext", "anotherFile.ext"], | ||
theCommandRun()); | ||
test.done(); | ||
}); | ||
closeWith('[branchNameInHere CommitHash] Add nodeunit test runner\n\ | ||
3 files changed, 29 insertions(+), 12 deletions(-)\n\ | ||
create mode 100644 src/index.js'); | ||
}, | ||
'commit with no files specified': function (test) { | ||
@@ -123,2 +164,23 @@ git.commit('some message', function (err, commit) { | ||
'commit with no files specified and multiple line commit': function (test) { | ||
git.commit(['some', 'message'], function (err, commit) { | ||
test.equals('branchNameInHere', commit.branch, 'Should pick up branch name'); | ||
test.equals('CommitHash', commit.commit, 'Should pick up commit hash'); | ||
test.equals(3, commit.summary.changes, 'Should pick up changes count'); | ||
test.equals(12, commit.summary.deletions, 'Should pick up deletions count'); | ||
test.equals(10, commit.summary.insertions, 'Should pick up insertions count'); | ||
test.same( | ||
["commit", "-m", "some", "-m" ,"message"], | ||
theCommandRun()); | ||
test.done(); | ||
}); | ||
closeWith('[branchNameInHere CommitHash] Add nodeunit test runner\n\ | ||
3 files changed, 10 insertions(+), 12 deletions(-)\n\ | ||
create mode 100644 src/index.js'); | ||
}, | ||
'commit when no files are staged': function (test) { | ||
@@ -125,0 +187,0 @@ git.commit('some message', function (err, commit) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69999
1624