diff options
-rwxr-xr-x | radar-base.sh | 4 | ||||
-rwxr-xr-x | test-format-config.sh | 22 |
2 files changed, 23 insertions, 3 deletions
diff --git a/radar-base.sh b/radar-base.sh index 6458446..665b30a 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -499,8 +499,8 @@ render_prompt() { if [[ $PROMPT_FORMAT =~ ^.*%{branch}.*$ ]]; then branch_sed="s/%{branch}/$(readable_branch_name)/" fi - if [[ $PROMPT_FORMAT =~ ^.*%{local}.*$ ]]; then - local_sed="s/%{local}/$(color_local_commits)/" + if [[ $PROMPT_FORMAT =~ %{([^%{}]{1,}:){0,1}local(:[^%{}]{1,}){0,1}} ]]; then + local_sed="s/%{\(\([^%^{^}]*\)\:\)\{0,1\}local\(\:\([^%^{^}]*\)\)\{0,1\}}/\2$(color_local_commits)\4/" fi if [[ $PROMPT_FORMAT =~ %{([^%{}]{1,}:){0,1}changes(:[^%{}]{1,}){0,1}} ]]; then changes_sed="s/%{\(\([^%^{^}]*\)\:\)\{0,1\}changes\(\:\([^%^{^}]*\)\)\{0,1\}}/\2$(color_changes_status)\4/" diff --git a/test-format-config.sh b/test-format-config.sh index ce4645e..2a5226a 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -135,7 +135,7 @@ test_reorder_parts() { rm_tmp } -test_prefix_and_suffix() { +test_prefix_and_suffix_changes() { prepare_test_repo export GIT_RADAR_FORMAT="%{changes}" @@ -155,4 +155,24 @@ test_prefix_and_suffix() { rm_tmp } +test_prefix_and_suffix_local() { + prepare_test_repo + + export GIT_RADAR_FORMAT="%{local}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals " 1↑" "$prompt" + + export GIT_RADAR_FORMAT="%{[:local:]}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals "[ 1↑]" "$prompt" + + rm_tmp +} + . ./shunit/shunit2 |