Get the current state of any git repository.
npm install git-state
var git = require('git-state')
var path = '/path/to/git/repo'
if (git.isGit(path)) {
git.check(path, function (err, result) {
if (err) throw err
console.log(result) // => { branch: 'master',
// ahead: 0,
// dirty: 9,
// untracked: 1,
// issues: true }
})
}
Returns either true
or false
if the given path contains a git
repository.
Will check the state of the git repository at the given path
and call
the callback
. The callback
will be called with two arguments: An
optional error object and a result object.
The result object contains the following properties:
branch
- The currently checked out branchahead
- The amount of commits the current branch is ahead of the remote (may beNaN
if there for instance is no remote)dirty
- The number of dirty filesuntracked
- The number of untracked filesissues
- A generic boolean which istrue
if the repository is in a non-clean state (e.g. it's dirty, contains untracked files, is head of its remote or is currently not on master)
MIT