Socket
Socket
Sign inDemoInstall

simple-git

Package Overview
Dependencies
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-git - npm Package Compare versions

Comparing version 1.12.0 to 1.13.0

2

package.json
{
"name": "simple-git",
"description": "Simple GIT interface for node.js",
"version": "1.12.0",
"version": "1.13.0",
"author": "Steve King <steve@mydev.co>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -26,2 +26,4 @@ # Simple Git

`init(bare, handlerFn)` initialize a repository, optional `bare` parameter makes intialized repository bare.
`.clone(repoPath, localPath, handlerFn)` clone a remote repo at `repoPath` to a local directory at `localPath`

@@ -78,2 +80,4 @@

`.reset(resetMode, handlerFn)` resets the repository (resetMode can be 'hard' or 'soft', handlerFn: (err))
`.revparse([options], handlerFn)` wraps git rev-parse. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes. Options should be an array of string options compatible with the [git rev-parse](http://git-scm.com/docs/git-rev-parse)

@@ -87,3 +91,3 @@

`.listRemote([args], handlerFn)` lists remote repositories - there are so many optional arguments in the underlying
`git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))`.
`git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))`.

@@ -90,0 +94,0 @@ `outputHandler(handlerFn)` attaches a handler that will be called with the name of the command being run and the

@@ -72,7 +72,15 @@ (function () {

*
* @param {Boolean} [bare=false]
* @param {Function} [then]
*/
Git.prototype.init = function (then) {
return this._run(['init'], function (err) {
then && then(err);
Git.prototype.init = function (bare, then) {
var commands = ['init'];
var next = Git.trailingFunctionArgument(arguments);
if (bare === true) {
commands.push('--bare');
}
return this._run(commands, function (err) {
next && next(err);
});

@@ -235,2 +243,17 @@ };

/**
* Reset a repo
*
* @param {string} [mode=soft] Either 'soft' or 'hard'
* @param {Function} [then]
*/
Git.prototype.reset = function (mode, then) {
var resetMode = '--' + (mode === 'hard' ? mode : 'soft');
var next = (typeof arguments[arguments.length - 1] === "function") ? arguments[arguments.length - 1] : null;
return this._run(['reset', resetMode], function (err) {
next && next(err || null);
});
};
/**
* Add a lightweight tag to the head of the current branch

@@ -538,2 +561,6 @@ *

if (opt.n || opt['max-count']) {
command.push("--max-count=" + (opt.n || opt['max-count']));
}
return this._run(command, function (err, data) {

@@ -741,4 +768,13 @@ handler && handler(err, !err && this._parseListLog(data));

/**
* Given any number of arguments, returns the last argument if it is a function, otherwise returns null.
* @returns {Function|null}
*/
Git.trailingFunctionArgument = function (args) {
var trailing = args[args.length - 1];
return (typeof trailing === "function") ? trailing : null;
};
module.exports = Git;
}());

@@ -53,104 +53,2 @@

exports.status = {
setUp: function (done) {
Instance();
done();
},
'empty status': function (test) {
git.status(function (err, status) {
test.equals(0, status.created, 'No new files');
test.equals(0, status.deleted, 'No removed files');
test.equals(0, status.modified, 'No modified files');
test.equals(0, status.not_added, 'No untracked files');
test.done();
});
test.equals(1, mockChildProcesses.length, 'Spawns one process per task');
closeWith('');
},
'modified status': function (test) {
git.status(function (err, status) {
test.equals(3, status.created.length, 'No new files');
test.equals(0, status.deleted.length, 'No removed files');
test.equals(2, status.modified.length, 'No modified files');
test.equals(1, status.not_added.length, 'No un-tracked files');
test.done();
});
test.equals(1, mockChildProcesses.length, 'Spawns one process per task');
closeWith(' M package.json\n\
M src/git.js\n\
AM src/index.js \n\
A src/newfile.js \n\
AM test.js\n\
?? test/ \n\
');
}
};
exports.show = {
setUp: function (done) {
sandbox.stub(console, 'warn');
Instance();
done();
},
'allows the use of an array of options': function (test) {
git.show(['--abbrev-commit', 'foo', 'bar'], function (err, result) {
test.same(0, console.warn.callCount);
test.same(
["show", "--abbrev-commit", "foo", "bar"],
theCommandRun());
test.done();
});
closeWith('commit 2d4d33a\n\
Author: Some Name <some.name@gmail.com>\n\
Date: Sun Oct 11 00:06:10 2015 +0200\n\
\
Some commit message\n\
\
diff --git a/src/file.js b/src/file.js\n\
index ab02a9b..5000197 100644\n\
--- a/src/file.js\n\
+++ b/src/file.js\n\
@@ -468,8 +468,13 @@\n\
existing unchanged content\n\
- removed content\n\
+ added content\n\
remaining content\n');
},
'allows an options string': function (test) {
git.show('--abbrev-commit', function (err, result) {
test.same(1, console.warn.callCount);
test.same(
["show", "--abbrev-commit"],
theCommandRun());
test.done();
});
closeWith('commit 2d4d33a\n\
Author: Some Name <some.name@gmail.com>\n\
Date: Sun Oct 11 00:06:10 2015 +0200\n\
\
Some commit message\n\
\
diff --git a/src/file.js b/src/file.js\n\
index ab02a9b..5000197 100644\n\
--- a/src/file.js\n\
+++ b/src/file.js\n\
@@ -468,8 +468,13 @@\n\
existing unchanged content\n\
- removed content\n\
+ added content\n\
remaining content\n');
}
};
exports.commit = {

@@ -171,4 +69,4 @@ setUp: function (done) {

test.same(
["commit", "-m", "some message", "fileName.ext"],
theCommandRun());
["commit", "-m", "some message", "fileName.ext"],
theCommandRun());

@@ -193,4 +91,4 @@ test.done();

test.same(
["commit", "-m", "some message", "fileName.ext", "anotherFile.ext"],
theCommandRun());
["commit", "-m", "some message", "fileName.ext", "anotherFile.ext"],
theCommandRun());

@@ -215,4 +113,4 @@ test.done();

test.same(
["commit", "-m", "some message"],
theCommandRun());
["commit", "-m", "some message"],
theCommandRun());

@@ -250,2 +148,127 @@ test.done();

exports.init = {
setUp: function (done) {
Instance();
done();
},
'with just a handler': function (test) {
git.init(function (err) {
test.equals(null, err, 'not an error');
test.same(["init"], theCommandRun());
test.done();
});
closeWith('');
},
'as a bare repo': function (test) {
git.init(true, function (err) {
test.equals(null, err, 'not an error');
test.same(["init", "--bare"], theCommandRun());
test.done();
});
closeWith('');
},
'as a regular repo': function (test) {
git.init('truthy value', function (err) {
test.equals(null, err, 'not an error');
test.same(["init"], theCommandRun());
test.done();
});
closeWith('');
},
'no handler': function (test) {
git.init();
closeWith('');
setTimeout(function () {
test.same(["init"], theCommandRun());
test.done();
});
}
};
exports.log = {
setUp: function (done) {
Instance();
done();
},
'with max count shorthand property': function (test) {
git.log({n: 5}, function (err, result) {
test.equals(null, err, 'not an error');
test.same(["log", "--pretty=format:'%H;%ai;%s%d;%aN;%ae'", "--max-count=5"], theCommandRun());
test.done();
});
closeWith('17df9a7421dd86920cd20afd1d6b6be527a89b88;2015-11-24 11:55:47 +0100;add reset command;Mark Oswald;markoswald123@googlemail.com\n\
4e0d08e0653101fb4d8da3ea3420f5c490401e9e;2015-11-19 22:03:49 +0000;Release 1.12.0 (origin/master, origin/HEAD);Steve King;steve@mydev.co\n\
83f3f60d5899116fe4d38b9109c9d925963856da;2015-11-19 13:54:28 +0000;Merge pull request #51 from ebaioni/patch-1 (tag: 1.12.0);Steve King;steve@mydev.co\n\
c515d3f28f587312d816e14ef04db399b7e0adcd;2015-11-19 15:55:41 +1100;updates command to customBinary;Enrico Baioni;baio88@gmail.com\n\
570223e86f0999fd3b39280ad33081e5155d1003;2015-10-12 22:01:05 +0100;Release 1.11.0;Steve King;steve@mydev.co\
');
},
'with max count longhand property': function (test) {
git.log({n: 5}, function (err, result) {
test.equals(null, err, 'not an error');
test.same(["log", "--pretty=format:'%H;%ai;%s%d;%aN;%ae'", "--max-count=5"], theCommandRun());
test.done();
});
closeWith('17df9a7421dd86920cd20afd1d6b6be527a89b88;2015-11-24 11:55:47 +0100;add reset command;Mark Oswald;markoswald123@googlemail.com\n\
4e0d08e0653101fb4d8da3ea3420f5c490401e9e;2015-11-19 22:03:49 +0000;Release 1.12.0 (origin/master, origin/HEAD);Steve King;steve@mydev.co\n\
83f3f60d5899116fe4d38b9109c9d925963856da;2015-11-19 13:54:28 +0000;Merge pull request #51 from ebaioni/patch-1 (tag: 1.12.0);Steve King;steve@mydev.co\n\
c515d3f28f587312d816e14ef04db399b7e0adcd;2015-11-19 15:55:41 +1100;updates command to customBinary;Enrico Baioni;baio88@gmail.com\n\
570223e86f0999fd3b39280ad33081e5155d1003;2015-10-12 22:01:05 +0100;Release 1.11.0;Steve King;steve@mydev.co\
');
}
};
exports.reset = {
setUp: function (done) {
Instance();
done();
},
hard: function (test) {
git.reset('hard', function (err) {
test.equals(null, err, 'not an error');
test.same(
["reset", "--hard"],
theCommandRun());
test.done();
});
closeWith('');
},
soft: function (test) {
git.reset('soft', function (err) {
test.equals(null, err, 'not an error');
test.same(
["reset", "--soft"],
theCommandRun());
test.done();
});
closeWith('');
},
'no handler': function (test) {
git.reset();
closeWith('');
setTimeout(function () {
test.same(["reset", "--soft"], theCommandRun());
test.done();
});
}
};
exports.revParse = {

@@ -285,4 +308,4 @@ setUp: function (done) {

test.same(
["rev-parse", "some", "string"],
theCommandRun());
["rev-parse", "some", "string"],
theCommandRun());
test.done();

@@ -294,6 +317,108 @@ },

test.same(
["rev-parse", "another", "string"],
theCommandRun());
["rev-parse", "another", "string"],
theCommandRun());
test.done();
}
};
exports.show = {
setUp: function (done) {
sandbox.stub(console, 'warn');
Instance();
done();
},
'allows the use of an array of options': function (test) {
git.show(['--abbrev-commit', 'foo', 'bar'], function (err, result) {
test.same(0, console.warn.callCount);
test.same(
["show", "--abbrev-commit", "foo", "bar"],
theCommandRun());
test.done();
});
closeWith('commit 2d4d33a\n\
Author: Some Name <some.name@gmail.com>\n\
Date: Sun Oct 11 00:06:10 2015 +0200\n\
\
Some commit message\n\
\
diff --git a/src/file.js b/src/file.js\n\
index ab02a9b..5000197 100644\n\
--- a/src/file.js\n\
+++ b/src/file.js\n\
@@ -468,8 +468,13 @@\n\
existing unchanged content\n\
- removed content\n\
+ added content\n\
remaining content\n');
},
'allows an options string': function (test) {
git.show('--abbrev-commit', function (err, result) {
test.same(1, console.warn.callCount);
test.same(
["show", "--abbrev-commit"],
theCommandRun());
test.done();
});
closeWith('commit 2d4d33a\n\
Author: Some Name <some.name@gmail.com>\n\
Date: Sun Oct 11 00:06:10 2015 +0200\n\
\
Some commit message\n\
\
diff --git a/src/file.js b/src/file.js\n\
index ab02a9b..5000197 100644\n\
--- a/src/file.js\n\
+++ b/src/file.js\n\
@@ -468,8 +468,13 @@\n\
existing unchanged content\n\
- removed content\n\
+ added content\n\
remaining content\n');
}
};
exports.status = {
setUp: function (done) {
Instance();
done();
},
'empty status': function (test) {
git.status(function (err, status) {
test.equals(0, status.created, 'No new files');
test.equals(0, status.deleted, 'No removed files');
test.equals(0, status.modified, 'No modified files');
test.equals(0, status.not_added, 'No untracked files');
test.done();
});
test.equals(1, mockChildProcesses.length, 'Spawns one process per task');
closeWith('');
},
'modified status': function (test) {
git.status(function (err, status) {
test.equals(3, status.created.length, 'No new files');
test.equals(0, status.deleted.length, 'No removed files');
test.equals(2, status.modified.length, 'No modified files');
test.equals(1, status.not_added.length, 'No un-tracked files');
test.done();
});
test.equals(1, mockChildProcesses.length, 'Spawns one process per task');
closeWith(' M package.json\n\
M src/git.js\n\
AM src/index.js \n\
A src/newfile.js \n\
AM test.js\n\
?? test/ \n\
');
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc