Skip to content

Commit

Permalink
implement stash_count
Browse files Browse the repository at this point in the history
  • Loading branch information
Spitfire1900 committed Mar 28, 2024
1 parent 547b2f6 commit eee7bf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'gitstatus.short_head': <Prompt: gitstatus.short_head>, # DONE
'gitstatus.tag': <Prompt: gitstatus.tag>, # PARTIAL
'gitstatus.tag_or_hash': <Prompt: gitstatus.tag_or_hash>, # TODO
'gitstatus.stash_count': <Prompt: gitstatus.stash_count>, # TODO
'gitstatus.stash_count': <Prompt: gitstatus.stash_count>, # DONE
'gitstatus.operations': <Prompt: gitstatus.operations>, # TODO
'gitstatus.porcelain': <Prompt: gitstatus.porcelain>, # TODO
'gitstatus.branch': <Prompt: gitstatus.branch>, # DONE
Expand Down
4 changes: 2 additions & 2 deletions xontrib/pygitstatus/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from xonsh.built_ins import XonshSession

from .prompts import (ahead, behind, branch, clean, repo_path, short_head, tag,
untracked)
from .prompts import (ahead, behind, branch, clean, repo_path, short_head, stash_count, tag, untracked)


def _load_xontrib_(xsh: XonshSession, **_):
Expand All @@ -24,6 +23,7 @@ def _load_xontrib_(xsh: XonshSession, **_):
prompt_fields['pygitstatus.clean'] = clean
prompt_fields['pygitstatus.repo_path'] = repo_path
prompt_fields['pygitstatus.short_head'] = short_head
prompt_fields['pygitstatus.stash_count'] = stash_count
prompt_fields['pygitstatus.tag'] = tag
prompt_fields['pygitstatus.untracked'] = untracked

Expand Down
10 changes: 10 additions & 0 deletions xontrib/pygitstatus/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def short_head(fld: PromptField, ctx: PromptFields):
fld.value = local_commit.short_id


@PromptField.wrap(prefix="⚑")
def stash_count(fld: PromptField, ctx: PromptFields):
fld.value = ''
with contextlib.suppress(GitError):
repo = Repo('.')
_stash_count = len(repo.listall_stashes())
if _stash_count > 0:
fld.value = str(_stash_count)


@PromptField.wrap()
def tag(fld: PromptField, ctx: PromptFields):
fld.value = ''
Expand Down

0 comments on commit eee7bf1

Please sign in to comment.