fallback to using git binary to determine branch when necessary

This commit is contained in:
adam j hartz 2015-03-20 17:51:14 -04:00
parent 34c03a87a5
commit 38ee9195e6

View file

@ -44,6 +44,18 @@ def current_branch(cwd=None):
except subprocess.CalledProcessError:
continue
# fall back to using the git binary if the above failed
if branch is None:
try:
s = subprocess.check_output(['git', 'rev-parse','--abbrev-ref', 'HEAD'],
stderr=subprocess.PIPE, cwd=cwd,
universal_newlines=True)
s = s.strip()
if s != '':
branch = s
except:
pass
return branch