mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
Merge branch 'wrywerytwreywery-git_branch'
This commit is contained in:
commit
afaed78cdf
1 changed files with 12 additions and 0 deletions
|
@ -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 len(s) > 0:
|
||||
branch = s
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
return branch
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue