mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 17:30:59 +01:00
fix for no branch in pwd
This commit is contained in:
parent
724e8e5861
commit
752fe1f7f0
2 changed files with 22 additions and 17 deletions
|
@ -23,18 +23,18 @@ from xonsh.prompt.gitstatus import gitstatus_prompt
|
|||
@xl.lazyobject
|
||||
def FORMATTER_DICT():
|
||||
return dict(
|
||||
user=os.environ.get('USERNAME' if xp.ON_WINDOWS else 'USER', '<user>'),
|
||||
prompt_end='#' if xt.is_superuser() else '$',
|
||||
hostname=socket.gethostname().split('.', 1)[0],
|
||||
cwd=_dynamically_collapsed_pwd,
|
||||
cwd_dir=lambda: os.path.dirname(_replace_home_cwd()),
|
||||
cwd_base=lambda: os.path.basename(_replace_home_cwd()),
|
||||
short_cwd=_collapsed_pwd,
|
||||
curr_branch=current_branch,
|
||||
branch_color=branch_color,
|
||||
branch_bg_color=branch_bg_color,
|
||||
current_job=_current_job,
|
||||
env_name=env_name,
|
||||
vte_new_tab_cwd=vte_new_tab_cwd,
|
||||
gitstatus=gitstatus_prompt,
|
||||
user=os.environ.get('USERNAME' if xp.ON_WINDOWS else 'USER', '<user>'),
|
||||
prompt_end='#' if xt.is_superuser() else '$',
|
||||
hostname=socket.gethostname().split('.', 1)[0],
|
||||
cwd=_dynamically_collapsed_pwd,
|
||||
cwd_dir=lambda: os.path.dirname(_replace_home_cwd()),
|
||||
cwd_base=lambda: os.path.basename(_replace_home_cwd()),
|
||||
short_cwd=_collapsed_pwd,
|
||||
curr_branch=current_branch,
|
||||
branch_color=branch_color,
|
||||
branch_bg_color=branch_bg_color,
|
||||
current_job=_current_job,
|
||||
env_name=env_name,
|
||||
vte_new_tab_cwd=vte_new_tab_cwd,
|
||||
gitstatus=gitstatus_prompt,
|
||||
)
|
||||
|
|
|
@ -85,12 +85,17 @@ def current_branch(pad=NotImplemented):
|
|||
branch = None
|
||||
cmds = builtins.__xonsh_commands_cache__
|
||||
if cmds.lazy_locate_binary('git') or cmds.is_empty():
|
||||
branch = xonsh.prompt.gitstatus.gitstatus().branch
|
||||
if (cmds.lazy_locate_binary('hg') or cmds.is_empty()) and not branch:
|
||||
try:
|
||||
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()
|
||||
if isinstance(branch, subprocess.TimeoutExpired):
|
||||
branch = '<branch-timeout>'
|
||||
_first_branch_timeout_message()
|
||||
# _first_branch_timeout_message()
|
||||
return branch or None
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue