diff options
-rwxr-xr-x | radar-base.sh | 4 | ||||
-rwxr-xr-x | test-format-config.sh | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/radar-base.sh b/radar-base.sh index b7231de..6458446 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -502,8 +502,8 @@ render_prompt() { if [[ $PROMPT_FORMAT =~ ^.*%{local}.*$ ]]; then local_sed="s/%{local}/$(color_local_commits)/" fi - if [[ $PROMPT_FORMAT =~ ^.*%{changes}.*$ ]]; then - changes_sed="s/%{changes}/$(color_changes_status)/" + if [[ $PROMPT_FORMAT =~ %{([^%{}]{1,}:){0,1}changes(:[^%{}]{1,}){0,1}} ]]; then + changes_sed="s/%{\(\([^%^{^}]*\)\:\)\{0,1\}changes\(\:\([^%^{^}]*\)\)\{0,1\}}/\2$(color_changes_status)\4/" fi sed \ diff --git a/test-format-config.sh b/test-format-config.sh index e595703..ce4645e 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -135,4 +135,24 @@ test_reorder_parts() { rm_tmp } +test_prefix_and_suffix() { + prepare_test_repo + + export GIT_RADAR_FORMAT="%{changes}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals " 1A" "$prompt" + + export GIT_RADAR_FORMAT="%{[:changes:]}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals "[ 1A]" "$prompt" + + rm_tmp +} + . ./shunit/shunit2 |