Created
August 21, 2015 17:26
-
-
Save linus-amg/419033b2d0c1b930f6b1 to your computer and use it in GitHub Desktop.
nodegit get status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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