Skip to content

Instantly share code, notes, and snippets.

@akonwi
Created November 13, 2015 04:35
Show Gist options
  • Save akonwi/c101c7d25bc9c01646f3 to your computer and use it in GitHub Desktop.
Save akonwi/c101c7d25bc9c01646f3 to your computer and use it in GitHub Desktop.
gitStagedFiles = (repo, stdout) ->
files = []
gitCmd
args: ['diff-index', '--cached', 'HEAD', '--name-status', '-z']
cwd: repo.getWorkingDirectory()
stdout: (data) ->
files = _prettify(data)
stderr: (data) ->
# edge case of no HEAD at initial commit
if data.toString().includes "ambiguous argument 'HEAD'"
files = [1]
else
notifier.addError data.toString()
files = []
exit: (code) -> stdout(files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment