git-wrapper2 v0.2.5
git-wrapper2
A wrapper around the git executable. Built on top of the original git-wrapper, git-wrapper2 provides additional convenience functions for commit git tasks, like commiting changes and pushing them to a remote repository. Additionally git-wrapper2 emits events for many tasks so that you can observe changes throughout your application.
Installation
npm install git-wrapper2API
var git = new Git(options);
Constructor. See git(1) for available options.
optionsObject. Examples:{ paginate: true }enables pagination.{ 'git-dir': '../.git' }specifies a different.gitdirectory.
git.exec(command [, options, args], callback);
Executes a git command. See the Git Reference for available commands.
commandString. Examples:'init','log','commit', etc.optionsObject. The options for a git command. E.g.{ f: true }to force a command (equivalent to adding-fon the command line).argsArrayString. The arguments for a git command. E.g. some files forgit add.callbackFunction.callback(err, msg).
git.isRepo(callback);
Checks to see if the directory is a git repository. Callback returns a boolean indicating whether it is or not.
callbackFunction.callback(isRepo).
git.clone(repo, dir, callback);
Clones a repository to the destination dir.
repoString. Remote repository.dirString. Local directory to clone into.cal.backFunction.callback(err, msg).
git.pull(remote, branch, callback)
Performs a git pull command against the repository. If remote or branch are not provided they will default to origin and master respectively.
remoteString. Name of the remote target.branchString. Branch name to pull.callbackFunction.callback(err, msg).
git.add(which, callback)
Perform a git add command, staging files for a commit.
whichString. Which files to stage, seperated by spaces.callbackFunction.callback(err, msg).
git.commit(msg, callback)
Commits staged changes with the given msg as the commit message.
msgString. Body of the commit message.callbackFunction.callback(err, msg).
git.push(remote, branch, callback)
Pushes changes in the local repository to a remote. If remote or branch are not provided, the defaults will be origin and master respectively.
remoteString. Name of the remote target.callbackFunction.callback(err, msg).
git.save(msg, callback)
Convenience function for performing git.add, git.commit, and git.push in one function call. Using this will automatically stage all unstaged changes, commit, and then push.
msgString. Body of the commit message.callbackFunction.callback(err, msg).
git.log(options, callback)
Performs a git log command, returning the results. options are an array of command line options you might want to provide, such as ['-n', 2] to limit the results to only the last 2 commits.
optionsArray. Command line options for thegit logcommand.calllbackFunction.callback(err, msg).
Events
Several events are emitted when actions are performed against a git repository.
clone
Emitted when the repository is cloned.
commit
Emitted when a commit occurs.
saved
Emitted when a full save operation is performed and completed.
Bugs and Issues
If you encounter any bugs or issues, feel free to email me at matthew at matthewphillips.info.