Browse Source

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 years ago
parent
commit
6e8c5b7678
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      utils/torch_utils.py

+ 2
- 1
utils/torch_utils.py View File

# 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:
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: except subprocess.CalledProcessError as e:
return '' return ''



Loading…
Cancel
Save