fb66b67d683935cd0e4a5282064947a28087a91b

Author
Lennart Ochel <lennart.ochel@vti.se>
Committer
GitHub <noreply@github.com>
Date

Message

feat(git-prompt): show deleted files (#11245)

Diff

 1diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
 2index 0485e317cfcb4a648f36d9d1cf3b6603aab4f5b2..dcda418cfae88ac3db40bd8f16459fc4c2eb63f1 100644
 3--- a/plugins/git-prompt/git-prompt.plugin.zsh
 4+++ b/plugins/git-prompt/git-prompt.plugin.zsh
 5@@ -47,6 +47,7 @@ function update_current_git_vars() {
 6     GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
 7     GIT_STASHED=$__CURRENT_GIT_STATUS[8]
 8     GIT_CLEAN=$__CURRENT_GIT_STATUS[9]
 9+    GIT_DELETED=$__CURRENT_GIT_STATUS[10]
10 }
11 
12 git_super_status() {
13@@ -69,6 +70,9 @@ git_super_status() {
14       if [ "$GIT_CHANGED" -ne "0" ]; then
15           STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
16       fi
17+      if [ "$GIT_DELETED" -ne "0" ]; then
18+          STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DELETED$GIT_DELETED%{${reset_color}%}"
19+      fi
20       if [ "$GIT_UNTRACKED" -ne "0" ]; then
21           STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}"
22       fi
23@@ -91,6 +95,7 @@ ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
24 ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}"
25 ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}"
26 ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}"
27+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[blue]%}%{-%G%}"
28 ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
29 ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
30 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}"
31diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
32index b5c3c9a0c9fdcaeddcb0c64d897737ea003da8b6..94774d828ae57e63b0b58a7a9de23d5157ca3b02 100644
33--- a/plugins/git-prompt/gitstatus.py
34+++ b/plugins/git-prompt/gitstatus.py
35@@ -44,7 +44,7 @@ if po.returncode != 0:
36     sys.exit(0)  # Not a git repository
37 
38 # collect git status information
39-untracked, staged, changed, conflicts = [], [], [], []
40+untracked, staged, changed, deleted, conflicts = [], [], [], [], []
41 ahead, behind = 0, 0
42 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()]
43 for st in status:
44@@ -75,13 +75,15 @@ for st in status:
45     else:
46         if st[1] == 'M':
47             changed.append(st)
48+        if st[1] == 'D':
49+            deleted.append(st)
50         if st[0] == 'U':
51             conflicts.append(st)
52         elif st[0] != ' ':
53             staged.append(st)
54 
55 stashed = get_stash()
56-if not changed and not staged and not conflicts and not untracked:
57+if not changed and not deleted and not staged and not conflicts and not untracked:
58     clean = 1
59 else:
60     clean = 0
61@@ -95,6 +97,7 @@ out = ' '.join([
62     str(len(changed)),
63     str(len(untracked)),
64     str(stashed),
65-    str(clean)
66+    str(clean),
67+    str(len(deleted))
68 ])
69 print(out, end='')