simple-git
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -26,4 +26,10 @@ # Simple Git | ||
`.clone(repoPath, localPath, handlerFn)` clone a remote repo at `repoPath` to a local directory at `localPath` | ||
`.pull(handlerFn)` pull all updates from the repo | ||
`.fetch(remote, branch, handlerFn)` update the local working copy database with changes from a remote repo | ||
`.fetch(handlerFn)` update the local working copy database with changes from the default remote repo and branch | ||
`.tags(handlerFn)` list all tags | ||
@@ -76,8 +82,8 @@ | ||
require('simple-git')() | ||
.init() | ||
.add('./*') | ||
.commit("first commit!") | ||
.addRemote('origin', 'https://github.com/user/repo.git') | ||
.push('origin', 'master'); | ||
.init() | ||
.add('./*') | ||
.commit("first commit!") | ||
.addRemote('origin', 'https://github.com/user/repo.git') | ||
.push('origin', 'master'); | ||
@@ -28,2 +28,15 @@ (function() { | ||
/** | ||
* Clone a git repo | ||
* | ||
* @param {String} repoPath | ||
* @param {String} localPath | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.clone = function(repoPath, localPath, then ) { | ||
return this._run('git clone ' + repoPath + ' ' + localPath, function(err) { | ||
then && then(err); | ||
}); | ||
}; | ||
/** | ||
* Internally uses pull and tags to get the list of tags then checks out the latest tag. | ||
@@ -86,2 +99,27 @@ * | ||
/** | ||
* Fetch the updated contents of the current repo. | ||
* | ||
* @example | ||
* .fetch('upstream', 'master') // fetches from master on remote named upstream | ||
* .fetch(function () {}) // runs fetch against default remote and branch and calls function | ||
* | ||
* @param {String} [remote] | ||
* @param {String} [branch] | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.fetch = function(remote, branch, then) { | ||
var command = "git fetch"; | ||
if (typeof remote === 'string' && typeof branch === 'string') { | ||
command += ' "' + remote + '" "' + branch + '"'; | ||
} | ||
if (typeof arguments[arguments.length - 1] === 'function') { | ||
then = arguments[arguments.length - 1]; | ||
} | ||
return this._run(command, function(err, data) { | ||
then && then(err, !err && this._parsePush(data)); | ||
}); | ||
}; | ||
/** | ||
* List all tags | ||
@@ -296,2 +334,6 @@ * | ||
Git.prototype._parseFetch = function(fetch) { | ||
return data; | ||
}; | ||
Git.prototype._run = function(command, then) { | ||
@@ -298,0 +340,0 @@ this._runCache.push([command, then]); |
15555
349
88