From 014acde79daee83e1f1801412cc7a48293e6e1f2 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 12 Apr 2022 17:26:53 +0200 Subject: [PATCH] Update `git_describe()` (#7402) * Update `git_describe()` Add .git path check to avoid `fatal: not a git repository (or any of the parent directories): .git` printout * Update general.py --- utils/general.py | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/general.py b/utils/general.py index 6c2558d..daef2a4 100755 --- a/utils/general.py +++ b/utils/general.py @@ -275,6 +275,7 @@ def check_online(): def git_describe(path=ROOT): # path must be a directory # Return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe try: + assert (Path(path) / '.git').is_dir() return check_output(f'git -C {path} describe --tags --long --always', shell=True).decode()[:-1] except Exception: return ''