From 0b49a3cef7c112103000036204fefef08ace9b38 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 28 Mar 2021 17:09:06 +0200 Subject: [PATCH] Improve git_describe() fix 1 (#2635) Add stderr=subprocess.STDOUT to catch error messages. (cherry picked from commit 2e95cf3d794fe8b04dadea63d8cab523b959d853) --- utils/torch_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index dfab83d5374a..d6da0cae8945 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -55,10 +55,9 @@ def git_describe(path=Path(__file__).parent): # path must be a directory # return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe s = f'git -C {path} describe --tags --long --always' try: - r = subprocess.check_output(s, shell=True).decode()[:-1] - return '' if r.startswith('fatal: not a git repository') else r + return subprocess.check_output(s, shell=True, stderr=subprocess.STDOUT).decode()[:-1] except subprocess.CalledProcessError as e: - return '' + return '' # not a git repository def select_device(device='', batch_size=None):