simple-git
Advanced tools
Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -17,2 +17,14 @@ (function() { | ||
/** | ||
* Initalize a git repo | ||
* | ||
* @param {Object} options | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.init = function(then) { | ||
return this._run('git init', function(err) { | ||
then && then(err); | ||
}); | ||
}; | ||
/** | ||
* Internally uses pull and tags to get the list of tags then checks out the latest tag. | ||
@@ -93,2 +105,31 @@ * @param {Function} [then] | ||
/** | ||
* Add a submodule | ||
* | ||
* @param {String} repo | ||
* @param {String} path | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.submoduleAdd = function(repo, path, then) { | ||
return this._run('git submodule add "' + repo + '" "' + path + '"', function(err) { | ||
then && then(err); | ||
}); | ||
}; | ||
/** | ||
* List remote | ||
* | ||
* @param {String} args | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.listRemote = function(args, then) { | ||
if (!then && typeof args === "function") { | ||
then = args; | ||
args = ''; | ||
} | ||
return this._run('git ls-remote ' + args, function(err, data) { | ||
then && then(err, data); | ||
}); | ||
}; | ||
Git.prototype._parsePull = function(pull) { | ||
@@ -158,3 +199,3 @@ var changes = { | ||
var branch = /\[([^\s]+) ([^\]]+)/.exec(lines.shift()); | ||
var summary = /(\d+)[^\d]+(\d+)[^\d]+(\d+)/.exec(lines.pop()); | ||
var summary = /(\d+)[^,]*(?:,\s*(\d+)[^,]*)?(?:,\s*(\d+))?/g.exec(lines.shift()) || []; | ||
@@ -165,5 +206,5 @@ return { | ||
summary: { | ||
changes: summary[1], | ||
insertions: summary[2], | ||
deletions: summary[3] | ||
changes: (typeof summary[1] !== 'undefined') ? summary[1] : 0, | ||
insertions: (typeof summary[2] !== 'undefined') ? summary[2] : 0, | ||
deletions: (typeof summary[3] !== 'undefined') ? summary[3] : 0 | ||
} | ||
@@ -170,0 +211,0 @@ }; |
10406
239