Unverified 提交 2e95cf3d authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Improve git_describe() fix 1 (#2635)

Add stderr=subprocess.STDOUT to catch error messages.
上级 518c0957
...@@ -55,10 +55,9 @@ def git_describe(path=Path(__file__).parent): # path must be a directory ...@@ -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 # 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' s = f'git -C {path} describe --tags --long --always'
try: try:
r = subprocess.check_output(s, shell=True).decode()[:-1] return subprocess.check_output(s, shell=True, stderr=subprocess.STDOUT).decode()[:-1]
return '' if r.startswith('fatal: not a git repository') else r
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
return '' return '' # not a git repository
def select_device(device='', batch_size=None): def select_device(device='', batch_size=None):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论