diff options
Diffstat (limited to '')
| -rwxr-xr-x | radar-base.sh | 21 | ||||
| -rwxr-xr-x | test | 1 | ||||
| -rwxr-xr-x | test-format-config.sh | 27 | 
3 files changed, 44 insertions, 5 deletions
diff --git a/radar-base.sh b/radar-base.sh index e21122a..066da99 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -488,16 +488,27 @@ show_remote_status() {  }  render_prompt() { -  if [[ $PROMPT_FORMAT =~ ^.*%{remote}.*$ ]]; then -    zsh_color_remote_commits +  output="$PROMPT_FORMAT" +  branch_sed="" +  remote_sed="" +  local_sed="" +  changes_sed="" +  if [[ $output =~ ^.*%{remote}.*$ ]]; then +    remote_sed="s/%{remote}/$(zsh_color_remote_commits)/"    fi    if [[ $PROMPT_FORMAT =~ ^.*%{branch}.*$ ]]; then -    zsh_readable_branch_name +    branch_sed="s/%{branch}/$(zsh_readable_branch_name)/"    fi    if [[ $PROMPT_FORMAT =~ ^.*%{local}.*$ ]]; then -    zsh_color_local_commits +    local_sed="s/%{local}/$(zsh_color_local_commits)/"    fi    if [[ $PROMPT_FORMAT =~ ^.*%{changes}.*$ ]]; then -    zsh_color_changes_status +    changes_sed="s/%{changes}/$(zsh_color_changes_status)/"    fi + +  sed \ +    -e "$remote_sed" \ +    -e "$branch_sed" \ +    -e "$changes_sed" \ +    -e "$local_sed" <<<"$output"  } @@ -7,3 +7,4 @@  ./test-files.sh  ./test-status.sh  ./test-colors.sh +./test-format-config.sh diff --git a/test-format-config.sh b/test-format-config.sh index 17c4bd6..e595703 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -108,4 +108,31 @@ test_all_options_set_config() {    rm_tmp  } +test_reorder_parts() { +  prepare_test_repo + +  export GIT_RADAR_FORMAT="%{branch}%{local}%{changes}%{remote}" +  prepare_zsh_colors +  unset_colours + +  prompt="$(render_prompt)" +  assertEquals "foo 1↑ 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" + +  export GIT_RADAR_FORMAT="%{changes}%{remote}%{branch}%{local}" +  prepare_zsh_colors +  unset_colours + +  prompt="$(render_prompt)" +  assertEquals " 1Am 1 → foo 1↑" "$prompt" + +  rm_tmp +} +  . ./shunit/shunit2  | 
