From 7c8df909da46d9385844526eb3eaf26f916522ac Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 4 Aug 2019 03:21:26 -0700 Subject: [PATCH] add shorten_hash --- lethe.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lethe.py b/lethe.py index 1855c84..fa34b68 100755 --- a/lethe.py +++ b/lethe.py @@ -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) +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: """ Get the root directory of a git repository