diff options
author | Michael Allen <michael@michaelallen.io> | 2015-09-17 10:49:37 +0100 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-09-17 10:49:37 +0100 |
commit | 7fd5ee18bb412e3ee4db694f551a9b9421e18f89 (patch) | |
tree | 8fff433f1a61bcb697e4f8d2f7060e19a866d9bb | |
parent | 01bcac0242e4b44c796cdd88c1f87c66c5fdf158 (diff) | |
download | git-sonar-7fd5ee18bb412e3ee4db694f551a9b9421e18f89.tar.gz git-sonar-7fd5ee18bb412e3ee4db694f551a9b9421e18f89.zip |
Add prefix and suffix to branch name render
-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 a1ea097..be92bb2 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -502,8 +502,8 @@ render_prompt() { if [[ $output =~ ^.*%{remote}.*$ ]]; then remote_sed="s/%{remote}/$(color_remote_commits)/" fi - if [[ $PROMPT_FORMAT =~ ^.*%{branch}.*$ ]]; then - branch_sed="s/%{branch}/$(readable_branch_name)/" + if [[ $PROMPT_FORMAT =~ ${if_pre}branch${if_post} ]]; then + branch_sed="s/${sed_pre}branch${sed_post}/\2$(readable_branch_name)\4/" fi if [[ $PROMPT_FORMAT =~ ${if_pre}local${if_post} ]]; then local_sed="s/${sed_pre}local${sed_post}/\2$(color_local_commits)\4/" diff --git a/test-format-config.sh b/test-format-config.sh index 2a5226a..4283025 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -175,4 +175,24 @@ test_prefix_and_suffix_local() { rm_tmp } +test_prefix_and_suffix_branch() { + prepare_test_repo + + export GIT_RADAR_FORMAT="%{branch}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals "foo" "$prompt" + + export GIT_RADAR_FORMAT="%{[:branch:]}" + prepare_zsh_colors + unset_colours + + prompt="$(render_prompt)" + assertEquals "[foo]" "$prompt" + + rm_tmp +} + . ./shunit/shunit2 |