simple-git
Advanced tools
Comparing version 1.6.0 to 1.7.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -24,2 +24,3 @@ "contributors": [ | ||
], | ||
"license": "MIT", | ||
"repository": "git://github.com/steveukx/git-js.git", | ||
@@ -26,0 +27,0 @@ "main": "src/index.js", |
@@ -69,2 +69,4 @@ # Simple Git | ||
`.revparse(command, handlerFn)` where the command should be an array of string options compatible with the [git rev-parse](http://git-scm.com/docs/git-rev-parse) | ||
`.rm([fileA, ...], handlerFn)` removes any number of files from source control | ||
@@ -78,2 +80,4 @@ | ||
`.revparse([options], handlerFn)` wraps git rev-parse. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes. | ||
`.status(handlerFn)` gets the status of the current repo | ||
@@ -80,0 +84,0 @@ |
@@ -435,2 +435,29 @@ (function () { | ||
/** | ||
* rev-parse. | ||
* | ||
* @param {String|String[]} [options] | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.revparse = function(options, then) { | ||
var command = ['rev-parse']; | ||
if (typeof options === 'string') { | ||
command = command + ' ' + options; | ||
this._getLog('warn', | ||
'Git#revparse: supplying options as a single string is now deprecated, switch to an array of strings'); | ||
} | ||
else if (Array.isArray(options)) { | ||
command.push.apply(command, options); | ||
} | ||
if (typeof arguments[arguments.length - 1] === 'function') { | ||
then = arguments[arguments.length - 1]; | ||
} | ||
return this._run(command, function(err, data) { | ||
then && then(err, data); | ||
}); | ||
}; | ||
/** | ||
* Show various types of objects, for example the file at a certain commit | ||
@@ -437,0 +464,0 @@ * |
@@ -38,8 +38,14 @@ | ||
var sinon = require('sinon'); | ||
var sinon = require('sinon'), sandbox; | ||
var git, mockChildProcess, mockChildProcesses = []; | ||
exports.setUp = function (done) { | ||
sandbox = sinon.sandbox.create(); | ||
done(); | ||
}; | ||
exports.tearDown = function (done) { | ||
git = mockChildProcess = null; | ||
mockChildProcesses = []; | ||
sandbox.restore(); | ||
done(); | ||
@@ -131,3 +137,72 @@ }; | ||
create mode 100644 src/index.js'); | ||
}, | ||
'commit with no files specified': 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 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'); | ||
} | ||
}; | ||
exports.revParse = { | ||
setUp: function (done) { | ||
Instance(); | ||
git.silent(false); | ||
sandbox.stub(console, 'warn'); | ||
done(); | ||
}, | ||
'deprecated usage': function (test) { | ||
var then = sinon.spy(); | ||
git.revparse('HEAD', then); | ||
closeWith(''); | ||
test.ok(then.calledOnce); | ||
test.ok(then.calledWith(null, '')); | ||
test.ok(console.warn.calledOnce); | ||
test.done(); | ||
}, | ||
'valid usage': function (test) { | ||
var then = sinon.spy(); | ||
git.revparse(['HEAD'], then); | ||
closeWith(''); | ||
test.ok(then.calledOnce); | ||
test.ok(then.calledWith(null, '')); | ||
test.ok(console.warn.notCalled); | ||
test.done(); | ||
}, | ||
'called with a string': function (test) { | ||
git.revparse('some string'); | ||
test.same( | ||
["rev-parse", "some", "string"], | ||
theCommandRun()); | ||
test.done(); | ||
}, | ||
'called with an array of strings': function (test) { | ||
git.revparse(['another', 'string']); | ||
test.same( | ||
["rev-parse", "another", "string"], | ||
theCommandRun()); | ||
test.done(); | ||
} | ||
}; |
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
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
38988
0
854
163