add shorten_hash

This commit is contained in:
Jan Petykiewicz 2019-08-04 03:21:26 -07:00
parent 650960e10f
commit 7c8df909da

View File

@ -40,6 +40,13 @@ def get_latest_commit(short: bool=True, cwd: str=None) -> str:
return _run('git log --all -1 --format=%{}'.format(fmt), cwd=cwd) return _run('git log --all -1 --format=%{}'.format(fmt), cwd=cwd)
def shorten_hash(sha: str, cwd: str=None) -> str:
"""
Get the short version of a hash
"""
return _run('git rev-parse --short {}'.format(sha), cwd=cwd)
def get_root(cwd: str=None) -> str: def get_root(cwd: str=None) -> str:
""" """
Get the root directory of a git repository Get the root directory of a git repository