1
0
Fork 0

Add rudimentary error-state detection in git-info

* If status_cmd fails, increment the error count
* Add :prezto:module:git:info:error (%E) to format error count
pull/1665/head
Zoey Llewellyn Hewll 7 years ago
parent a338cba805
commit 5ea4b989b1

@ -139,6 +139,9 @@ function git-info {
local dirty=0 local dirty=0
local dirty_format local dirty_format
local dirty_formatted local dirty_formatted
local error=0
local error_format
local error_formatted
local ignore_submodules local ignore_submodules
local indexed=0 local indexed=0
local indexed_format local indexed_format
@ -351,6 +354,7 @@ function git-info {
else else
# Use porcelain status for easy parsing. # Use porcelain status for easy parsing.
status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}" status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}"
${(z)status_cmd} &> /dev/null || error=1
# Get current status. # Get current status.
while IFS=$'\n' read line; do while IFS=$'\n' read line; do
@ -411,6 +415,12 @@ function git-info {
zstyle -s ':prezto:module:git:info:clean' format 'clean_formatted' zstyle -s ':prezto:module:git:info:clean' format 'clean_formatted'
fi fi
# Format error.
if (( error > 0 )); then
zstyle -s ':prezto:module:git:info:error' format 'error_format'
zformat -f error_formatted "$error_format" "E:$error"
fi
# Format info. # Format info.
zstyle -a ':prezto:module:git:info:keys' format 'info_formats' zstyle -a ':prezto:module:git:info:keys' format 'info_formats'
for info_format in ${(k)info_formats}; do for info_format in ${(k)info_formats}; do
@ -423,6 +433,7 @@ function git-info {
"c:$commit_formatted" \ "c:$commit_formatted" \
"d:$deleted_formatted" \ "d:$deleted_formatted" \
"D:$dirty_formatted" \ "D:$dirty_formatted" \
"E:$error_formatted" \
"i:$indexed_formatted" \ "i:$indexed_formatted" \
"I:$unindexed_formatted" \ "I:$unindexed_formatted" \
"m:$modified_formatted" \ "m:$modified_formatted" \

Loading…
Cancel
Save