simple-git
Advanced tools
Comparing version 0.11.0 to 0.12.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -67,2 +67,4 @@ # Simple Git | ||
`.status(handlerFn)` gets the status of the current repo | ||
`.listRemote([args], handlerFn)` lists remote repositories - there are so many optional arguments in the underlying | ||
@@ -73,3 +75,3 @@ `git ls-remote` call, just supply any you want to use as the optional `args` string. | ||
`stdout` and `stderr` [readable streams](http://nodejs.org/api/stream.html#stream_class_stream_readable) created by | ||
the [child process](http://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command. | ||
the [child process](http://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command. | ||
@@ -76,0 +78,0 @@ # Examples |
@@ -72,2 +72,13 @@ (function() { | ||
/** | ||
* Check the status of the local repo | ||
* | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.status = function(then) { | ||
return this._run(['status --porcelain'], function(err,data) { | ||
then && then(err, !err && this._parseStatus(data)); | ||
}); | ||
}; | ||
/** | ||
* Clone a git repo | ||
@@ -413,2 +424,34 @@ * | ||
Git.prototype._parseStatus = function(status) { | ||
var line; | ||
var lines = status.trim().split('\n'); | ||
var not_added = []; | ||
var deleted = []; | ||
var modified = []; | ||
while (line = lines.shift()) { | ||
line = line.split(" "); | ||
var st = line.shift(); | ||
switch (st) { | ||
case "??": | ||
not_added.push(line.join()); | ||
break; | ||
case "D": | ||
deleted.push(line.join()); | ||
break; | ||
case "M": | ||
modified.push(line.join()); | ||
break; | ||
} | ||
} | ||
return { | ||
not_added: not_added, | ||
deleted: deleted, | ||
modified: modified | ||
}; | ||
}; | ||
Git.prototype._parseCommit = function(commit) { | ||
@@ -415,0 +458,0 @@ var lines = commit.trim().split('\n'); |
21362
493
113