Make _git_str() more reliable
This commit is contained in:
parent
39ed73c3cf
commit
fecfc86bc0
@ -64,11 +64,18 @@ def _git_str():
|
|||||||
Return None if there was an error or we're not in a git repo.
|
Return None if there was an error or we're not in a git repo.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# FIXME this runs in PWD, not the qutebrowser dir?!
|
if hasattr(sys, "frozen"):
|
||||||
if not os.path.isdir(".git"):
|
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output(['git', 'describe', '--tags', '--dirty',
|
gitpath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
'--always']).decode('UTF-8').strip()
|
os.path.pardir, os.path.pardir)
|
||||||
|
except NameError:
|
||||||
|
return None
|
||||||
|
if not os.path.isdir(os.path.join(gitpath, ".git")):
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
return subprocess.check_output(
|
||||||
|
['git', '-C', gitpath, 'describe', '--tags', '--dirty',
|
||||||
|
'--always']).decode('UTF-8').strip()
|
||||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user