From 650960e10f0e1d034c19c5011ed511817a6e4edc Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 4 Aug 2019 03:21:07 -0700 Subject: [PATCH] add get_latest_commit() --- lethe.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lethe.py b/lethe.py index 825fcbe..1855c84 100755 --- a/lethe.py +++ b/lethe.py @@ -31,6 +31,15 @@ def _run(command: str or List[str], **kwargs): return result.stdout.decode().strip() +def get_latest_commit(short: bool=True, cwd: str=None) -> str: + """ + Get the most recent commit's hash. + This includes non-lethe commits. + """ + fmt = 'h' if short else 'H' + return _run('git log --all -1 --format=%{}'.format(fmt), cwd=cwd) + + def get_root(cwd: str=None) -> str: """ Get the root directory of a git repository