fix for no branch in pwd

This commit is contained in:
laerus 2016-09-13 21:24:21 +03:00
parent 724e8e5861
commit 752fe1f7f0
2 changed files with 22 additions and 17 deletions

View file

@ -85,12 +85,17 @@ def current_branch(pad=NotImplemented):
branch = None branch = None
cmds = builtins.__xonsh_commands_cache__ cmds = builtins.__xonsh_commands_cache__
if cmds.lazy_locate_binary('git') or cmds.is_empty(): if cmds.lazy_locate_binary('git') or cmds.is_empty():
branch = xonsh.prompt.gitstatus.gitstatus().branch try:
if (cmds.lazy_locate_binary('hg') or cmds.is_empty()) and not branch: status = xonsh.prompt.gitstatus.gitstatus()
except subprocess.CalledProcessError:
branch = None
else:
branch = status.branch
elif (cmds.lazy_locate_binary('hg') or cmds.is_empty()) and not branch:
branch = get_hg_branch() branch = get_hg_branch()
if isinstance(branch, subprocess.TimeoutExpired): if isinstance(branch, subprocess.TimeoutExpired):
branch = '<branch-timeout>' branch = '<branch-timeout>'
_first_branch_timeout_message() # _first_branch_timeout_message()
return branch or None return branch or None