Skip to content

Commit

Permalink
Improve git_describe() (ultralytics#2633)
Browse files Browse the repository at this point in the history
Catch 'fatal: not a git repository' returns and return '' instead (observed in GCP Hub checks).
  • Loading branch information
glenn-jocher committed Mar 28, 2021
1 parent 9b92d3e commit 6e8c5b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''

Expand Down

0 comments on commit 6e8c5b7

Please sign in to comment.