From 2dbf0c220fc971c9493392a70c71954001fee7fd Mon Sep 17 00:00:00 2001 From: Claudio Bandera Date: Sun, 30 Aug 2015 23:04:16 +0200 Subject: Fixed unittests for Ubuntu --- radar-base.sh | 2 +- test-branches.sh | 3 ++- test-commits.sh | 8 +++----- test-directories.sh | 4 +++- test-files.sh | 51 ++++++++++++++++++++++++++------------------------- test-status.sh | 1 + 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index b7074d8..8d18fe3 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -62,7 +62,7 @@ record_timestamp() { timestamp() { if is_repo; then - printf '%s' "$(stat -f%m "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + printf '%s' "$(stat -c %Y "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" fi } diff --git a/test-branches.sh b/test-branches.sh index c886e82..b972a25 100755 --- a/test-branches.sh +++ b/test-branches.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -94,7 +95,7 @@ test_remote_branch_name_quiet_when_not_in_repo() { echo "$debug_output" - assertEquals " 0" "$usages" + assertEquals "0" "$usages" rm_tmp } diff --git a/test-commits.sh b/test-commits.sh index 95addf9..89a1ba1 100755 --- a/test-commits.sh +++ b/test-commits.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -14,7 +15,6 @@ rm_tmp() { cd $scriptDir rm -rf /tmp/git-prompt-tests* } - test_commits_with_no_commits() { cd_to_tmp git init --quiet @@ -222,7 +222,6 @@ test_remote_branch_starts_with_local_branch_name() { rm_tmp } - test_remote_branch_ends_with_local_branch_name() { cd_to_tmp "remote" git init --bare --quiet @@ -297,11 +296,10 @@ test_dont_call_remote_branch_name() { usages="$(echo "$debug_output" | grep 'remote_branch_name' | wc -l )" #wc -l has a weird output - assertEquals " 0" "$usages" + assertEquals "0" "$usages" rm_tmp } - test_dont_remote_if_remote_is_master() { cd_to_tmp git init --quiet @@ -322,7 +320,7 @@ test_dont_remote_if_remote_is_master() { usages="$(echo "$debug_output" | grep 'git rev-list' | wc -l )" - assertEquals " 0" "$usages" + assertEquals "0" "$usages" rm_tmp } diff --git a/test-directories.sh b/test-directories.sh index 86a441e..83c408f 100755 --- a/test-directories.sh +++ b/test-directories.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -63,7 +64,8 @@ test_record_timestamp_in_repo() { test_time_to_update_when_timestamp_is_old() { cd $scriptDir - touch -A "-010000" "$(dot_git)/lastupdatetime" + newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M) + touch -t $newtimestamp "$(dot_git)/lastupdatetime" assertTrue time_to_update } diff --git a/test-files.sh b/test-files.sh index 8f46edf..47d6922 100755 --- a/test-files.sh +++ b/test-files.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -24,7 +25,7 @@ test_untracked_files() { touch foo assertEquals "1A" "$(untracked_status)" - git add . + git add --all assertEquals "" "$(untracked_status)" rm_tmp @@ -38,7 +39,7 @@ test_unstaged_modified_files() { touch foo touch bar - git add . + git add --all git commit -m "foo and bar" >/dev/null echo "foo" >> foo @@ -58,7 +59,7 @@ test_unstaged_deleted_files() { touch foo touch bar - git add . + git add --all git commit -m "foo and bar" >/dev/null rm foo @@ -77,11 +78,11 @@ test_staged_added_files() { assertEquals "" "$(staged_status)" touch foo - git add . + git add --all assertEquals "1A" "$(staged_status)" touch bar - git add . + git add --all assertEquals "2A" "$(staged_status)" rm_tmp @@ -95,15 +96,15 @@ test_staged_modified_files() { touch foo touch bar - git add . + git add --all git commit -m "foo and bar" >/dev/null echo "foo" >> foo - git add . + git add --all assertEquals "1M" "$(staged_status)" echo "bar" >> bar - git add . + git add --all assertEquals "2M" "$(staged_status)" rm_tmp @@ -117,15 +118,15 @@ test_staged_deleted_files() { touch foo touch bar - git add . + git add --all git commit -m "foo and bar" >/dev/null rm foo - git add . + git add --all assertEquals "1D" "$(staged_status)" rm bar - git add . + git add --all assertEquals "2D" "$(staged_status)" rm_tmp @@ -139,15 +140,15 @@ test_staged_renamed_files() { touch foo touch bar - git add . + git add --all git commit -m "foo and bar" >/dev/null mv foo foo2 - git add . + git add --all assertEquals "1R" "$(staged_status)" mv bar bar2 - git add . + git add --all assertEquals "2R" "$(staged_status)" rm_tmp @@ -159,17 +160,17 @@ test_conflicted_both_changes() { git checkout -b foo --quiet echo "foo" >> foo - git add . + git add --all git commit -m "foo" --quiet git checkout -b foo2 --quiet echo "bar" >> foo - git add . + git add --all git commit -m "bar" --quiet git checkout foo --quiet echo "foo2" >> foo - git add . + git add --all git commit -m "foo2" --quiet assertEquals "" "$(conflicted_status)" @@ -187,17 +188,17 @@ test_conflicted_them_changes() { git checkout -b foo --quiet echo "foo" >> foo - git add . + git add --all git commit -m "foo" --quiet git checkout -b foo2 --quiet rm foo - git add . + git add --all git commit -m "delete foo" --quiet git checkout foo --quiet echo "foo2" >> foo - git add . + git add --all git commit -m "foo2" --quiet assertEquals "" "$(conflicted_status)" @@ -215,17 +216,17 @@ test_conflicted_us_changes() { git checkout -b foo --quiet echo "foo" >> foo - git add . + git add --all git commit -m "foo" --quiet git checkout -b foo2 --quiet echo "bar" >> foo - git add . + git add --all git commit -m "bar" --quiet git checkout foo --quiet rm foo - git add . + git add --all git commit -m "delete foo" --quiet assertEquals "" "$(conflicted_status)" @@ -254,7 +255,7 @@ test_is_dirty() { cd ../ - git add . + git add --all assertTrue "staged addition files" is_dirty git commit -m "inital commit" --quiet @@ -264,7 +265,7 @@ test_is_dirty() { echo "foo" >> foo assertTrue "modified file unstaged" is_dirty - git add . + git add --all assertTrue "modified file staged" is_dirty rm_tmp diff --git a/test-status.sh b/test-status.sh index 8c6bf89..99aebdf 100755 --- a/test-status.sh +++ b/test-status.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" -- cgit v1.2.3 From e692cbc483f8ee4b4666143fe1b3cfbd86e7681f Mon Sep 17 00:00:00 2001 From: Claudio Bandera Date: Thu, 17 Sep 2015 20:35:34 +0200 Subject: Added switch case for OS type in tests --- test-branches.sh | 9 +++++++-- test-colors.sh | 11 ++++++----- test-commits.sh | 14 ++++++++++++-- test-directories.sh | 8 ++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/test-branches.sh b/test-branches.sh index b3f0ac2..891a819 100755 --- a/test-branches.sh +++ b/test-branches.sh @@ -97,8 +97,13 @@ test_remote_branch_name_quiet_when_not_in_repo() { echo "$debug_output" - assertEquals "0" "$usages" - + if [[ $OSTYPE == darwin* ]];then + expected=" 0" + else + expected="0" + fi; + assertEquals "$expected" "$usages" + rm_tmp } diff --git a/test-colors.sh b/test-colors.sh index 73c20f7..116e09d 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -296,7 +297,7 @@ test_bash_colors_local() { assertEquals "$expected" "$(color_local_commits)" git push --quiet >/dev/null - git reset --hard head^ --quiet >/dev/null + git reset --hard HEAD^ --quiet >/dev/null printf -v expected " 1\x01local-behind\x02↓\x01local-reset\x02" assertEquals "$expected" "$(bash_color_local_commits)" @@ -340,7 +341,7 @@ test_zsh_colors_local() { assertEquals " 1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)" git push --quiet >/dev/null - git reset --hard head^ --quiet >/dev/null + git reset --hard HEAD^ --quiet >/dev/null assertEquals " 1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)" @@ -376,7 +377,7 @@ test_bash_colors_remote() { git push --quiet -u origin master >/dev/null repoLocation="$(pwd)" - git reset --hard head^ --quiet >/dev/null + git reset --hard HEAD^ --quiet >/dev/null git checkout -b mybranch --quiet git push --quiet -u origin mybranch >/dev/null @@ -387,7 +388,7 @@ test_bash_colors_remote() { echo "bar" > bar git add . git commit -m "new commit" --quiet - git push --quiet >/dev/null + git push --quiet origin mybranch >/dev/null printf -v expected "m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 " assertEquals "$expected" "$(bash_color_remote_commits)" @@ -426,7 +427,7 @@ test_zsh_colors_remote() { git push --quiet -u origin master >/dev/null repoLocation="$(pwd)" - git reset --hard head^ --quiet >/dev/null + git reset --hard HEAD^ --quiet >/dev/null git checkout -b mybranch --quiet git push --quiet -u origin mybranch >/dev/null diff --git a/test-commits.sh b/test-commits.sh index 8eecffc..c97c56a 100755 --- a/test-commits.sh +++ b/test-commits.sh @@ -296,7 +296,12 @@ test_dont_call_remote_branch_name() { usages="$(echo "$debug_output" | grep 'remote_branch_name' | wc -l )" #wc -l has a weird output - assertEquals "0" "$usages" + if [[ $OSTYPE == darwin* ]];then + expected=" 0" + else + expected="0" + fi; + assertEquals "$expected" "$usages" rm_tmp } @@ -320,7 +325,12 @@ test_dont_remote_if_remote_is_master() { usages="$(echo "$debug_output" | grep 'git rev-list' | wc -l )" - assertEquals "0" "$usages" + if [[ $OSTYPE == darwin* ]];then + expected=" 0" + else + expected="0" + fi; + assertEquals "$expected" "$usages" rm_tmp } diff --git a/test-directories.sh b/test-directories.sh index 83c408f..1777e69 100755 --- a/test-directories.sh +++ b/test-directories.sh @@ -64,8 +64,12 @@ test_record_timestamp_in_repo() { test_time_to_update_when_timestamp_is_old() { cd $scriptDir - newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M) - touch -t $newtimestamp "$(dot_git)/lastupdatetime" + if [[ $OSTYPE == darwin* ]];then + touch -A "-010000" "$(dot_git)/lastupdatetime" + else + newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M) + touch -t $newtimestamp "$(dot_git)/lastupdatetime" + fi; assertTrue time_to_update } -- cgit v1.2.3 From a7f6b47969e9c734ff28f5b49fdbbee6a6095b93 Mon Sep 17 00:00:00 2001 From: Claudio Bandera Date: Thu, 17 Sep 2015 20:41:00 +0200 Subject: Found another difference in syntax --- radar-base.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 41f4512..f346b26 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -131,7 +131,12 @@ record_timestamp() { timestamp() { if is_repo; then - printf '%s' "$(stat -c %Y "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + if [[ $OSTYPE == darwin* ]];then + printf '%s' "$(stat -f%m "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + else + printf '%s' "$(stat -c %Y "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")" + fi; + fi } -- cgit v1.2.3 From 096877942309a4bed2ac3e4fb0d4fcb962fe557f Mon Sep 17 00:00:00 2001 From: Claudio Bandera Date: Fri, 16 Oct 2015 16:52:53 +0200 Subject: Added missing shebang line to new test files --- test-format-config.sh | 1 + test-radar-base.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test-format-config.sh b/test-format-config.sh index 5504ebc..0bf01ac 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" diff --git a/test-radar-base.sh b/test-radar-base.sh index 9f7f8ee..ca1ddfd 100755 --- a/test-radar-base.sh +++ b/test-radar-base.sh @@ -1,3 +1,4 @@ +#!/bin/bash scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/radar-base.sh" @@ -25,4 +26,4 @@ test_show_remote_status() { assertFalse $? } -. ./shunit/shunit2 \ No newline at end of file +. ./shunit/shunit2 -- cgit v1.2.3 From d4a487f1fa4cc048f9ca50a3d47c4aa8d6dee8bd Mon Sep 17 00:00:00 2001 From: Claudio Bandera Date: Sun, 24 Apr 2016 17:09:59 +0200 Subject: Merge remote-tracking branch 'upstream/master' into hotfix/unittests --- README.md | 22 +++++- git-radar | 2 + radar-base.sh | 58 ++++++++++---- test-directories.sh | 5 +- test-format-config.sh | 212 +++++++++++++++++++++++++------------------------- 5 files changed, 175 insertions(+), 124 deletions(-) diff --git a/README.md b/README.md index 2f508a8..2f4e39f 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Add to your `config.fish` function fish_prompt set_color $fish_color_cwd echo -n (prompt_pwd) - git-radar --fish --fetch + echo -n (git-radar --fish --fetch) set_color normal echo -n ' > ' end @@ -190,6 +190,25 @@ export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " ``` [(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution) +You may also choose to fetch at a customized interval of time. To do so, add +this to your .bashrc, .zshrc: + +```bash +export GIT_RADAR_FETCH_TIME= +``` + +For example, to fetch every 30 seconds (instead of the default 5 minutes): + +```bash +export GIT_RADAR_FETCH_TIME=30 +``` + +You can also do this in the gitradarrc file: + +```bash +GIT_RADAR_FETCH_TIME=30 +``` + ## Customise your prompt Git Radar is highly customisable using a prompt format string. The 4 features @@ -235,6 +254,7 @@ The default prompt format uses this to add spaces only if the feature would render. In that way the prompt always looks well spaced out no matter how many features are rendering. + ## Support ### Ensuring prompt execution diff --git a/git-radar b/git-radar index a8dd72e..f736e41 100755 --- a/git-radar +++ b/git-radar @@ -95,9 +95,11 @@ while [[ $# > 0 ]];do if [[ "$command" == "--fetch" ]]; then nohup $dot/fetch.sh >/dev/null 2>&1 & fi + if [[ "$command" == "--zsh" ]]; then $dot/prompt.zsh $args fi + if [[ "$command" == "--bash" || "$command" == "--fish" ]]; then $dot/prompt.bash $args fi diff --git a/radar-base.sh b/radar-base.sh index 60d5bd3..9d337cc 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -14,6 +14,20 @@ timethis() { echo "$1 - $dur" >> $HOME/duration.dat } +get_fetch_time() { + if [ -f "$rcfile_path/.gitradarrc.bash" ]; then + source "$rcfile_path/.gitradarrc.bash" + elif [ -f "$rcfile_path/.gitradarrc.zsh" ]; then + source "$rcfile_path/.gitradarrc.zsh" + elif [ -f "$rcfile_path/.gitradarrc" ]; then + source "$rcfile_path/.gitradarrc" + fi + + FETCH_TIME="${GIT_RADAR_FETCH_TIME:-"$((5 * 60))"}" + echo $FETCH_TIME + +} + prepare_bash_colors() { if [ -f "$rcfile_path/.gitradarrc.bash" ]; then source "$rcfile_path/.gitradarrc.bash" @@ -49,7 +63,7 @@ prepare_bash_colors() { RESET_COLOR_CHANGES="\x01${GIT_RADAR_COLOR_CHANGES_RESET:-"\\033[0m"}\x02" RESET_COLOR_BRANCH="\x01${GIT_RADAR_COLOR_BRANCH_RESET:-"\\033[0m"}\x02" RESET_COLOR_STASH="\x01${GIT_RADAR_COLOR_STASH:-"\\033[0m"}\x02" - + } prepare_zsh_colors() { @@ -76,7 +90,7 @@ prepare_zsh_colors() { COLOR_CHANGES_UNTRACKED="%{${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-$fg_bold[white]}%}" COLOR_STASH="%{${GIT_RADAR_COLOR_STASH:-$fg_bold[yellow]}%}" - + local italic_m="$(printf '\xF0\x9D\x98\xAE')" COLOR_BRANCH="%{${GIT_RADAR_COLOR_BRANCH:-$reset_color}%}" @@ -174,10 +188,10 @@ time_now() { } time_to_update() { + last_time_updated="${1:-$FETCH_TIME}" if is_repo; then local timesincelastupdate="$(($(time_now) - $(timestamp)))" - local fiveminutes="$((5 * 60))" - if (( $timesincelastupdate > $fiveminutes )); then + if (( $timesincelastupdate > $last_time_updated )); then # time to update return 0 (which is true) return 0 else @@ -190,7 +204,10 @@ time_to_update() { } fetch() { - if time_to_update; then + # Gives $FETCH_TIME a value + get_fetch_time + + if time_to_update $FETCH_TIME; then record_timestamp git fetch --quiet > /dev/null 2>&1 fi @@ -219,22 +236,25 @@ branch_ref() { } remote_branch_name() { - local localRef="\/$(branch_name)$" - if [[ -n "$localRef" ]]; then - local remoteBranch="$(git for-each-ref --format='%(upstream:short)' refs/heads $localRef 2>/dev/null | grep $localRef)" + local localRef="$(branch_name)" + local remote="$(git config --get "branch.$localRef.remote")" + if [[ -n $remote ]]; then + local remoteBranch="$(git config --get "branch.${localRef}.merge" | sed -e 's/^refs\/heads\///')" if [[ -n $remoteBranch ]]; then - printf '%s' $remoteBranch + printf '%s/%s' $remote $remoteBranch return 0 else - return 1 + return 1 fi + else + return 1 fi } commits_behind_of_remote() { remote_branch=${1:-"$(remote_branch_name)"} if [[ -n "$remote_branch" ]]; then - git rev-list --left-only --count ${remote_branch}...HEAD + git rev-list --left-only --count ${remote_branch}...HEAD 2>/dev/null else printf '%s' "0" fi @@ -243,7 +263,7 @@ commits_behind_of_remote() { commits_ahead_of_remote() { remote_branch=${1:-"$(remote_branch_name)"} if [[ -n "$remote_branch" ]]; then - git rev-list --right-only --count ${remote_branch}...HEAD + git rev-list --right-only --count ${remote_branch}...HEAD 2>/dev/null else printf '%s' "0" fi @@ -521,10 +541,16 @@ stashed_status() { printf '%s' "$(git stash list | wc -l 2>/dev/null | grep -oEi '[0-9][0-9]*')" } +is_cwd_a_dot_git_directory() { + [[ "$(basename $PWD)" == ".git" ]]; return $? +} + stash_status() { - local number_stashes="$(stashed_status)" - if [ $number_stashes -gt 0 ]; then - printf $PRINT_F_OPTION "$number_stashes$COLOR_STASH≡$RESET_COLOR_STASH" + if ! is_cwd_a_dot_git_directory; then + local number_stashes="$(stashed_status)" + if [ $number_stashes -gt 0 ]; then + printf $PRINT_F_OPTION "${number_stashes}${COLOR_STASH}≡${RESET_COLOR_STASH}" + fi fi } @@ -551,7 +577,7 @@ render_prompt() { fi fi if [[ $PROMPT_FORMAT =~ ${if_pre}branch${if_post} ]]; then - branch_result="$(readable_branch_name | sed -e 's/\//\\\//')" + branch_result="$(readable_branch_name | sed -e 's/\//\\\//g')" if [[ -n "$branch_result" ]]; then branch_sed="s/${sed_pre}branch${sed_post}/\2${branch_result}\4/" else diff --git a/test-directories.sh b/test-directories.sh index 1777e69..219a9f3 100755 --- a/test-directories.sh +++ b/test-directories.sh @@ -64,7 +64,8 @@ test_record_timestamp_in_repo() { test_time_to_update_when_timestamp_is_old() { cd $scriptDir - if [[ $OSTYPE == darwin* ]];then + FETCH_TIME="$((5 * 60))" # Fetch every 5 mins + if [[ $OSTYPE == darwin* ]];then touch -A "-010000" "$(dot_git)/lastupdatetime" else newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M) @@ -75,6 +76,7 @@ test_time_to_update_when_timestamp_is_old() { test_not_time_to_update_when_just_recorded() { cd $scriptDir + FETCH_TIME="$((5 * 60))" # Fetch every 5 mins record_timestamp assertFalse time_to_update } @@ -83,6 +85,7 @@ test_time_to_update_when_no_timestamp() { cd_to_tmp git init --quiet + FETCH_TIME="$((5 * 60))" # Fetch every 5 mins time_to_update assertTrue time_to_update diff --git a/test-format-config.sh b/test-format-config.sh index 0bf01ac..78a1c34 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -125,111 +125,111 @@ 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 "foo1↑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 →foo1↑" "$prompt" - - rm_tmp -} - -test_prefix_and_suffix_changes() { - 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 -} - -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 -} - -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 -} - -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 -} +#test_reorder_parts() { +# prepare_test_repo +# +# export GIT_RADAR_FORMAT="%{branch}%{local}%{changes}%{remote}" +# prepare_zsh_colors +# unset_colours +# +# prompt="$(render_prompt)" +# assertEquals "foo1↑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 →foo1↑" "$prompt" +# +# rm_tmp +#} +# +#test_prefix_and_suffix_changes() { +# 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 +#} +# +#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 +#} +# +#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 +#} +# +#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 -- cgit v1.2.3