Skip to content

Instantly share code, notes, and snippets.

@arush0311
Created January 17, 2017 21:29
Show Gist options
  • Save arush0311/0496cd5af13886712542cea7a71d5258 to your computer and use it in GitHub Desktop.
Save arush0311/0496cd5af13886712542cea7a71d5258 to your computer and use it in GitHub Desktop.
from subprocess import check_output, CalledProcessError
def get_commit_sha():
try:
commit = check_output(['git', 'rev-parse', 'HEAD'])
commit += check_output(['git', 'status', '--porcelain'])
commit = commit.decode('utf-8').strip()
except (OSError, CalledProcessError) as e:
commit = ''
return commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment