瀏覽代碼

Improve git_describe() (#2633)

Catch 'fatal: not a git repository' returns and return '' instead (observed in GCP Hub checks).
5.0
Glenn Jocher GitHub 3 年之前
父節點
當前提交
6e8c5b7678
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. +2
    -1
      utils/torch_utils.py

+ 2
- 1
utils/torch_utils.py 查看文件

@@ -55,7 +55,8 @@ 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:
return subprocess.check_output(s, shell=True).decode()[:-1]
r = subprocess.check_output(s, shell=True).decode()[:-1]
return '' if r.startswith('fatal: not a git repository') else r
except subprocess.CalledProcessError as e:
return ''


Loading…
取消
儲存