diff options
-rwxr-xr-x | radar-base.sh | 12 | ||||
-rwxr-xr-x | test-colors.sh | 12 | ||||
-rwxr-xr-x | test-commits.sh | 18 | ||||
-rwxr-xr-x | test-format-config.sh | 14 |
4 files changed, 27 insertions, 29 deletions
diff --git a/radar-base.sh b/radar-base.sh index 693d763..b85f75f 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -31,7 +31,7 @@ prepare_bash_colors() { COLOR_BRANCH="\x01${GIT_RADAR_COLOR_BRANCH:-"\\033[0m"}\x02" MASTER_SYMBOL="${GIT_RADAR_MASTER_SYMBOL:-"\\x01\\033[0m\\x02\\xF0\\x9D\\x98\\xAE\\x01\\033[0m\\x02"}" - PROMPT_FORMAT="${GIT_RADAR_FORMAT:-" \\x01\\033[1;30m\\x02git:(\\x01\\033[0m\\x02%{remote}%{branch}%{local}\\x01\\033[1;30m\\x02)\\x01\\033[0m\\x02%{changes}"}" + PROMPT_FORMAT="${GIT_RADAR_FORMAT:-" \\x01\\033[1;30m\\x02git:(\\x01\\033[0m\\x02%{remote}%{branch}%{ :local}\\x01\\033[1;30m\\x02)\\x01\\033[0m\\x02%{changes}"}" RESET_COLOR_LOCAL="\x01${GIT_RADAR_COLOR_LOCAL_RESET:-"\\033[0m"}\x02" RESET_COLOR_REMOTE="\x01${GIT_RADAR_COLOR_REMOTE_RESET:-"\\033[0m"}\x02" @@ -67,7 +67,7 @@ prepare_zsh_colors() { COLOR_BRANCH="%{${GIT_RADAR_COLOR_BRANCH:-$reset_color}%}" MASTER_SYMBOL="${GIT_RADAR_MASTER_SYMBOL:-"%{$reset_color%}$italic_m%{$reset_color%}"}" - PROMPT_FORMAT="${GIT_RADAR_FORMAT:-" $fg_bold[grey]git:($reset_color%{remote}%{branch}%{local}$fg_bold[grey])$reset_color%{changes}"}" + PROMPT_FORMAT="${GIT_RADAR_FORMAT:-" $fg_bold[grey]git:($reset_color%{remote}%{branch}%{ :local}$fg_bold[grey])$reset_color%{changes}"}" RESET_COLOR_LOCAL="%{${GIT_RADAR_COLOR_LOCAL_RESET:-$reset_color}%}" RESET_COLOR_REMOTE="%{${GIT_RADAR_COLOR_REMOTE_RESET:-$reset_color}%}" @@ -406,8 +406,6 @@ zsh_color_changes_status() { } color_local_commits() { - local separator="${1:- }" - local green_ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" local red_behind_arrow="${COLOR_LOCAL_BEHIND}↓$RESET_COLOR_LOCAL" local yellow_diverged_arrow="${COLOR_LOCAL_DIVERGED}⇵$RESET_COLOR_LOCAL" @@ -418,11 +416,11 @@ color_local_commits() { local_behind="$(commits_behind_of_remote "$remote_branch")" if [[ "$local_behind" -gt "0" && "$local_ahead" -gt "0" ]]; then - local_commits="$separator$local_behind$yellow_diverged_arrow$local_ahead" + local_commits="$local_behind$yellow_diverged_arrow$local_ahead" elif [[ "$local_behind" -gt "0" ]]; then - local_commits="$separator$local_behind$red_behind_arrow" + local_commits="$local_behind$red_behind_arrow" elif [[ "$local_ahead" -gt "0" ]]; then - local_commits="$separator$local_ahead$green_ahead_arrow" + local_commits="$local_ahead$green_ahead_arrow" fi fi printf $PRINT_F_OPTION "$local_commits" diff --git a/test-colors.sh b/test-colors.sh index 73c20f7..e28fb68 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -291,14 +291,14 @@ test_bash_colors_local() { git add . git commit -m "test commit" --quiet - printf -v expected " 1\x01local-ahead\x02↑\x01local-reset\x02" + printf -v expected "1\x01local-ahead\x02↑\x01local-reset\x02" assertEquals "$expected" "$(bash_color_local_commits)" assertEquals "$expected" "$(color_local_commits)" git push --quiet >/dev/null git reset --hard head^ --quiet >/dev/null - printf -v expected " 1\x01local-behind\x02↓\x01local-reset\x02" + printf -v expected "1\x01local-behind\x02↓\x01local-reset\x02" assertEquals "$expected" "$(bash_color_local_commits)" assertEquals "$expected" "$(color_local_commits)" @@ -306,7 +306,7 @@ test_bash_colors_local() { git add . git commit -m "new commit" --quiet - printf -v expected " 1\x01local-diverged\x02⇵\x01local-reset\x021" + printf -v expected "1\x01local-diverged\x02⇵\x01local-reset\x021" assertEquals "$expected" "$(bash_color_local_commits)" assertEquals "$expected" "$(color_local_commits)" @@ -337,18 +337,18 @@ test_zsh_colors_local() { git add . git commit -m "test commit" --quiet - assertEquals " 1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)" + assertEquals "1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)" git push --quiet >/dev/null git reset --hard head^ --quiet >/dev/null - assertEquals " 1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)" + assertEquals "1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)" echo "foo" > foo git add . git commit -m "new commit" --quiet - assertEquals " 1%{local-diverged%}⇵%{local-reset%}1" "$(zsh_color_local_commits)" + assertEquals "1%{local-diverged%}⇵%{local-reset%}1" "$(zsh_color_local_commits)" rm_tmp } diff --git a/test-commits.sh b/test-commits.sh index 1a4a86c..6c317f9 100755 --- a/test-commits.sh +++ b/test-commits.sh @@ -402,9 +402,9 @@ test_local_commits() { git add . git commit -m "test commit" --quiet - assertEquals " 1$up" "$(zsh_color_local_commits)" - assertEquals " 1$up" "$(bash_color_local_commits)" - assertEquals " 1$up" "$(color_local_commits)" + assertEquals "1$up" "$(zsh_color_local_commits)" + assertEquals "1$up" "$(bash_color_local_commits)" + assertEquals "1$up" "$(color_local_commits)" cd "$remote" echo "foo" > foo @@ -414,15 +414,15 @@ test_local_commits() { cd "$repo" git fetch origin --quiet - assertEquals " 1${both}1" "$(zsh_color_local_commits)" - assertEquals " 1${both}1" "$(bash_color_local_commits)" - assertEquals " 1${both}1" "$(color_local_commits)" + assertEquals "1${both}1" "$(zsh_color_local_commits)" + assertEquals "1${both}1" "$(bash_color_local_commits)" + assertEquals "1${both}1" "$(color_local_commits)" git reset --hard HEAD^ --quiet - assertEquals " 1$down" "$(zsh_color_local_commits)" - assertEquals " 1$down" "$(bash_color_local_commits)" - assertEquals " 1$down" "$(color_local_commits)" + assertEquals "1$down" "$(zsh_color_local_commits)" + assertEquals "1$down" "$(bash_color_local_commits)" + assertEquals "1$down" "$(color_local_commits)" } . ./shunit/shunit2 diff --git a/test-format-config.sh b/test-format-config.sh index 8b786c9..036a87b 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -75,7 +75,7 @@ test_all_options_set_config() { unset_colours prompt="$(render_prompt)" - assertEquals "$prompt" "m 1 → foo 1↑ 1A" + assertEquals "$prompt" "m 1 → foo1↑ 1A" export GIT_RADAR_FORMAT="%{remote}%{branch}%{changes}" prepare_zsh_colors @@ -89,7 +89,7 @@ test_all_options_set_config() { unset_colours prompt="$(render_prompt)" - assertEquals "$prompt" "foo 1↑ 1A" + assertEquals "$prompt" "foo1↑ 1A" export GIT_RADAR_FORMAT="%{branch}%{changes}" prepare_zsh_colors @@ -116,21 +116,21 @@ test_reorder_parts() { unset_colours prompt="$(render_prompt)" - assertEquals "foo 1↑ 1Am 1 → " "$prompt" + assertEquals "foo1↑ 1Am 1 → " "$prompt" export GIT_RADAR_FORMAT="%{local}%{changes}%{remote}%{branch}" prepare_zsh_colors unset_colours prompt="$(render_prompt)" - assertEquals " 1↑ 1Am 1 → foo" "$prompt" + assertEquals "1↑ 1Am 1 → foo" "$prompt" export GIT_RADAR_FORMAT="%{changes}%{remote}%{branch}%{local}" prepare_zsh_colors unset_colours prompt="$(render_prompt)" - assertEquals " 1Am 1 → foo 1↑" "$prompt" + assertEquals " 1Am 1 → foo1↑" "$prompt" rm_tmp } @@ -163,14 +163,14 @@ test_prefix_and_suffix_local() { unset_colours prompt="$(render_prompt)" - assertEquals " 1↑" "$prompt" + assertEquals "1↑" "$prompt" export GIT_RADAR_FORMAT="%{[:local:]}" prepare_zsh_colors unset_colours prompt="$(render_prompt)" - assertEquals "[ 1↑]" "$prompt" + assertEquals "[1↑]" "$prompt" rm_tmp } |