diff --git a/TODO.md b/TODO.md index 438ef98..748c627 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ 'gitstatus.ahead': , # DONE 'gitstatus.behind': , # DONE 'gitstatus.untracked': , # DONE -'gitstatus.changed': , # PARTIAL +'gitstatus.changed': , # DONE 'gitstatus.deleted': , # DONE 'gitstatus.conflicts': , # DONE 'gitstatus.staged': , # DONE @@ -31,6 +31,7 @@ - branch_color - ALL Prompts need the name field set. - Prompts like deleted, changed, etc. need to consider that status() combines the INDEX and WT status + ```python """ GIT_STATUS_INDEX_DELETED: 4 @@ -40,6 +41,8 @@ GIT_STATUS_INDEX_TYPECHANGE: 16 GIT_STATUS_WT_DELETED: 512 GIT_STATUS_WT_MODIFIED: 256 + + GIT_STATUS_WT_NEW: 128 GIT_STATUS_WT_RENAMED: 2048 GIT_STATUS_WT_TYPECHANGE: 1024 diff --git a/xontrib/pygitstatus/prompts.py b/xontrib/pygitstatus/prompts.py index 07e2679..93dca4d 100644 --- a/xontrib/pygitstatus/prompts.py +++ b/xontrib/pygitstatus/prompts.py @@ -103,12 +103,19 @@ def branch(fld: PromptField, ctx: PromptFields): name='pygitstatus.changed') def changed(fld: PromptField, ctx: PromptFields): fld.value = '' + count = 0 + with contextlib.suppress(GitError): repo = Repo('.') - untracked_count = len( - [v for k, v in repo.status().items() if v == GIT_STATUS_WT_MODIFIED]) - if untracked_count > 0: - fld.value = str(untracked_count) + + for k, v in repo.status().items(): + statuses = __git_status_calulator(v) + # We don't care about the index + is_true = GIT_STATUS_WT_MODIFIED in statuses + if is_true: + count = count + 1 + if count > 0: + fld.value = str(count) @PromptField.wrap(prefix="{RED}×", suffix="{RESET}", info="conflicts", @@ -149,25 +156,19 @@ def curr_branch() -> Optional[str]: name='pygitstatus.deleted') def deleted(fld: PromptField, ctx: PromptFields): fld.value = '' - deleted_count = 0 + count = 0 with contextlib.suppress(GitError): repo = Repo('.') for k, v in repo.status().items(): statuses = __git_status_calulator(v) - is_deleted = False - for status in statuses: - if status in [ - GIT_STATUS_INDEX_DELETED, - GIT_STATUS_WT_DELETED, - ]: - is_deleted = True - break - if is_deleted: - deleted_count = deleted_count + 1 - if deleted_count > 0: - fld.value = str(deleted_count) + # We don't care about the index. + is_true = GIT_STATUS_WT_DELETED in statuses + if is_true: + count = count + 1 + if count > 0: + fld.value = str(count) @PromptField.wrap(prefix="{CYAN}+", suffix="{RESET}", name='pygitstatus.lines_added')