From c2dbe6f579bac9b40482970287e6a58783994257 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:22:13 +0100 Subject: Test zsh local commit colors --- radar-base.sh | 6 +++--- test-colors.sh | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index b2ecd38..63a18c9 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -430,9 +430,9 @@ bash_color_local_commits() { zsh_color_local_commits() { local separator="${1:- }" - local ahead_arrow="$COLOR_LOCAL_AHEAD↑$RESET_COLOR_LOCAL" - local behind_arrow="$COLOR_LOCAL_BEHIND↓$RESET_COLOR_LOCAL" - local diverged_arrow="$COLOR_LOCAL_DIVERGED⇵$RESET_COLOR_LOCAL" + local ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" + local behind_arrow="${COLOR_LOCAL_BEHIND}↓$RESET_COLOR_LOCAL" + local diverged_arrow="${COLOR_LOCAL_DIVERGED}⇵$RESET_COLOR_LOCAL" local local_commits="" if remote_branch="$(remote_branch_name)"; then diff --git a/test-colors.sh b/test-colors.sh index 712dad5..efcdea9 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -45,7 +45,7 @@ test_no_rcfile_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}" } -test_with_env_vars_zsh() { +set_zsh_env_vars() { export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" @@ -63,7 +63,10 @@ test_with_env_vars_zsh() { export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" +} +test_with_env_vars_zsh() { + set_zsh_env_vars mock_zsh_colors prepare_zsh_colors @@ -86,4 +89,42 @@ test_with_env_vars_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" } +test_zsh_colors_local() { + set_zsh_env_vars + prepare_zsh_colors + + cd_to_tmp "remote" + git init --bare --quiet + remoteLocation="$(pwd)" + + cd_to_tmp "repo" + git init --quiet + git remote add origin $remoteLocation + git fetch origin --quiet + git checkout -b master --quiet + touch README + git add README + git commit -m "initial commit" --quiet + git push --quiet -u origin master >/dev/null + repoLocation="$(pwd)" + + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + + 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)" + + echo "foo" > foo + git add . + git commit -m "new commit" --quiet + + assertEquals " 1%{local-diverged%}⇵%{local-reset%}1" "$(zsh_color_local_commits)" + + rm_tmp +} . ./shunit/shunit2 -- cgit v1.2.3