Skip to content

Commit

Permalink
always set fld.value to ''
Browse files Browse the repository at this point in the history
  • Loading branch information
Spitfire1900 committed Mar 28, 2024
1 parent 2a17812 commit 41104f3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions xontrib/pygitstatus/prompt.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import contextlib
import os

from pygit2 import Commit # pylint: disable=no-name-in-module
from pygit2 import GitError # pylint: disable=no-name-in-module
# pylint: disable=no-name-in-module
from pygit2 import GIT_STATUS_WT_NEW, Commit, GitError
from pygit2 import Repository as Repo
from xonsh.prompt.base import MultiPromptField, PromptField, PromptFields

Expand All @@ -11,6 +11,7 @@

@PromptField.wrap(prefix='↑·', info='ahead')
def ahead(fld: PromptField, ctx: PromptFields):
fld.value = ''
ahead, behind = (0, 0)
with contextlib.suppress(GitError):
repo = Repo('.')
Expand All @@ -26,6 +27,7 @@ def ahead(fld: PromptField, ctx: PromptFields):

@PromptField.wrap(prefix='↓·', info='behind')
def behind(fld: PromptField, ctx: PromptFields):
fld.value = ''
ahead, behind = (0, 0)
with contextlib.suppress(GitError):
repo = Repo('.')
Expand All @@ -41,6 +43,7 @@ def behind(fld: PromptField, ctx: PromptFields):

@PromptField.wrap(prefix='{CYAN}', info='branch')
def branch(fld: PromptField, ctx: PromptFields):
fld.value = ''
with contextlib.suppress(GitError):
repo = Repo('.')
fld.value = repo.head.shorthand
Expand All @@ -53,18 +56,17 @@ def clean(fld: PromptField, ctx: PromptFields):
symbol: str
symbol = fld.symbol # type: ignore

value = ''
fld.value = ''

with contextlib.suppress(GitError):
repo = Repo('.')
if len(repo.status()) == 0:
value = symbol

fld.value = value
fld.value = symbol


@PromptField.wrap()
def repo_path(fld: PromptField, ctx: PromptFields):
fld.value = ''
with contextlib.suppress(GitError):
repo = Repo('.')

Expand All @@ -75,6 +77,7 @@ def repo_path(fld: PromptField, ctx: PromptFields):

@PromptField.wrap(prefix=':')
def short_head(fld: PromptField, ctx: PromptFields):
fld.value = ''
with contextlib.suppress(GitError):
repo = Repo('.')
local_commit_hash = repo.head.target
Expand All @@ -84,6 +87,7 @@ def short_head(fld: PromptField, ctx: PromptFields):

@PromptField.wrap()
def tag(fld: PromptField, ctx: PromptFields):
fld.value = ''
with contextlib.suppress(GitError):
repo = Repo('.')
head_commit = repo.get(repo.head.target)
Expand Down

0 comments on commit 41104f3

Please sign in to comment.