Skip to content

Instantly share code, notes, and snippets.

@linus-amg
Created August 21, 2015 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linus-amg/419033b2d0c1b930f6b1 to your computer and use it in GitHub Desktop.
Save linus-amg/419033b2d0c1b930f6b1 to your computer and use it in GitHub Desktop.
nodegit get status
Git = require('nodegit')
pathToRepo = require('path').resolve(process.cwd())
module.exports = (socket, options) ->
Git.Repository.open(pathToRepo)
.then(getStatus)
.then (list) ->
console.log list
getStatus = (repository) ->
return repository.getStatus().then(processStatuses)
processStatuses = (statuses) ->
results = []
statuses.forEach (file) ->
results.push file.path() + ' ' + statusToText(file)
return results
statusToText = (status) ->
words = []
if status.isNew() then words.push('NEW')
if status.isModified() then words.push('MODIFIED')
if status.isTypechange() then words.push('TYPECHANGE')
if status.isRenamed() then words.push('RENAMED')
if status.isIgnored() then words.push('IGNORED')
return words.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment