glenn-jocher commited on
Commit
014acde
1 Parent(s): 2da2466

Update `git_describe()` (#7402)

Browse files

* Update `git_describe()`

Add .git path check to avoid `fatal: not a git repository (or any of the parent directories): .git` printout

* Update general.py

Files changed (1) hide show
  1. utils/general.py +1 -0
utils/general.py CHANGED
@@ -275,6 +275,7 @@ def check_online():
275
  def git_describe(path=ROOT): # path must be a directory
276
  # Return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe
277
  try:
 
278
  return check_output(f'git -C {path} describe --tags --long --always', shell=True).decode()[:-1]
279
  except Exception:
280
  return ''
 
275
  def git_describe(path=ROOT): # path must be a directory
276
  # Return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe
277
  try:
278
+ assert (Path(path) / '.git').is_dir()
279
  return check_output(f'git -C {path} describe --tags --long --always', shell=True).decode()[:-1]
280
  except Exception:
281
  return ''