summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-09-17 10:55:09 +0100
committerMichael Allen <michael@michaelallen.io>2015-09-17 10:55:09 +0100
commitd2c7ed085ff711a9f34fc1b0f521bcde253f19c5 (patch)
tree06f6cba4956a5b1b74d0893b701647562af64ad0
parent7fd5ee18bb412e3ee4db694f551a9b9421e18f89 (diff)
downloadgit-sonar-d2c7ed085ff711a9f34fc1b0f521bcde253f19c5.tar.gz
git-sonar-d2c7ed085ff711a9f34fc1b0f521bcde253f19c5.zip
Add prefix and suffixing to remote diff render
-rwxr-xr-xradar-base.sh4
-rwxr-xr-xtest-format-config.sh20
2 files changed, 22 insertions, 2 deletions
diff --git a/radar-base.sh b/radar-base.sh
index be92bb2..9e233ea 100755
--- a/radar-base.sh
+++ b/radar-base.sh
@@ -499,8 +499,8 @@ render_prompt() {
sed_pre="%{\(\([^%^{^}]*\)\:\)\{0,1\}"
sed_post="\(\:\([^%^{^}]*\)\)\{0,1\}}"
- if [[ $output =~ ^.*%{remote}.*$ ]]; then
- remote_sed="s/%{remote}/$(color_remote_commits)/"
+ if [[ $output =~ ${if_pre}remote${if_post} ]]; then
+ remote_sed="s/${sed_pre}remote${sed_post}/\2$(color_remote_commits)\4/"
fi
if [[ $PROMPT_FORMAT =~ ${if_pre}branch${if_post} ]]; then
branch_sed="s/${sed_pre}branch${sed_post}/\2$(readable_branch_name)\4/"
diff --git a/test-format-config.sh b/test-format-config.sh
index 4283025..8b786c9 100755
--- a/test-format-config.sh
+++ b/test-format-config.sh
@@ -195,4 +195,24 @@ test_prefix_and_suffix_branch() {
rm_tmp
}
+test_prefix_and_suffix_remote() {
+ prepare_test_repo
+
+ export GIT_RADAR_FORMAT="%{remote}"
+ prepare_zsh_colors
+ unset_colours
+
+ prompt="$(render_prompt)"
+ assertEquals "m 1 → " "$prompt"
+
+ export GIT_RADAR_FORMAT="%{[:remote:]}"
+ prepare_zsh_colors
+ unset_colours
+
+ prompt="$(render_prompt)"
+ assertEquals "[m 1 → ]" "$prompt"
+
+ rm_tmp
+}
+
. ./shunit/shunit2