From 5997057f7abb6ced9891f5288f0e08d4b1b73a2f Mon Sep 17 00:00:00 2001 From: Seth Mason Date: Thu, 1 Oct 2015 23:46:46 -0700 Subject: Fix #2 branches with same name in multiple remotes Use `git config` to get the correct upstream remote and branch when you have branch with the same name in multiple remotes (e.g. "origin/master" and "coworker/master"). Uses awk which may be a problem? --- radar-base.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index 258e5b1..6a9c630 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -199,10 +199,15 @@ 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)" - if [[ -n $remoteBranch ]]; then - printf '%s' $remoteBranch - return 0 + local remote="$(git config --get-regexp "^branch\.$localRef\.remote" | awk '{print $2}')" + if [[ -n $remote ]]; then + local remoteBranch="$(git config --get-regexp "^branch\.${localRef}\.merge" | awk -F'/' '{print $NF}')" + if [[ -n $remoteBranch ]]; then + printf '%s/%s' $remote $remoteBranch + return 0 + else + return 1 + fi else return 1 fi -- cgit v1.2.3 From 00f2a8c908e299d08e2efad038da25b2d5446976 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Mon, 28 Sep 2015 22:13:18 -0700 Subject: Added feature that let's you specify how often to fetch with --fetch_t you can specify how many seconds to wait before auto fetching. using the --fetch option gives you the default of 5 minutes still. "--fetch_t 45" for example would fetch every 45 seconds. --- fetch.sh | 6 +++++- git-radar | 21 +++++++++++++++++---- radar-base.sh | 12 +++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/fetch.sh b/fetch.sh index 37601e3..a3fc571 100755 --- a/fetch.sh +++ b/fetch.sh @@ -10,4 +10,8 @@ dot="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; p source $dot/radar-base.sh -fetch; +if [[ -z "$1" ]]; then + fetch; +else + fetch $1; +fi diff --git a/git-radar b/git-radar index 67b8460..c3f7aa3 100755 --- a/git-radar +++ b/git-radar @@ -56,10 +56,11 @@ if [[ -z $@ ]]; then echo "usage:" echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" - echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --zsh # Output prompt using Zsh style color characters" - echo " --bash # Output prompt using Bash style color characters" - echo " --fish # Output prompt using fish style color characters" + echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" + echo " --fetch_t # Fetches your repo asynchronously in the background every seconds" + echo " --zsh # Output prompt using Zsh style color characters" + echo " --bash # Output prompt using Bash style color characters" + echo " --fish # Output prompt using fish style color characters" echo "" echo "Bash example:" echo " export PS1=\"\\W\\\$(git-radar --bash --fetch) \"" @@ -83,18 +84,30 @@ if [[ -z $@ ]]; then echo " end" echo "" echo " Same as the Bash but for fish." + echo "" + echo "Fetch_t example:" + echo " export PS1=\"\\W\\\$(git-radar --bash --fetch_t 45) \"" exit fi while [[ $# > 0 ]];do command="$1" shift + # Default fetch of 5 min if [[ "$command" == "--fetch" ]]; then nohup $dot/fetch.sh >/dev/null 2>&1 & fi + + # Custom fetch of whatever time interval the user wants + if [[ "$command" == "--fetch_t" ]]; then + # Now $1 is the value of fetch_t + nohup $dot/fetch.sh $1 >/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 258e5b1..ee5fa00 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -154,8 +154,7 @@ time_now() { time_to_update() { if is_repo; then local timesincelastupdate="$(($(time_now) - $(timestamp)))" - local fiveminutes="$((5 * 60))" - if (( $timesincelastupdate > $fiveminutes )); then + if (( $timesincelastupdate > $1 )); then # time to update return 0 (which is true) return 0 else @@ -168,7 +167,14 @@ time_to_update() { } fetch() { - if time_to_update; then + if [ -z "$1" ]; then + # Default 5 minutes + local timeToUpdate="$((5 * 60))" + else + local timeToUpdate="$1" + fi + + if time_to_update $timeToUpdate; then record_timestamp git fetch --quiet > /dev/null 2>&1 fi -- cgit v1.2.3 From 9e46dc2520728237e48f9fea879b85601a3aebf3 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Mon, 28 Sep 2015 22:20:16 -0700 Subject: Updated readme with --fetch_t feature. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 3ef156d..c54764f 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,15 @@ export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " ``` [(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution) +You may also choose to use the `--fetch_t` option to specify your own fetch +times. `--fetch` defaults to fetch automatically every 5 minutes. With +`--fetch_t ` you can choose how often to fetch. + +eg. +```bash +export PS1="$PS1\$(git-radar --bash --fetch_t 30)" +``` + ## Customise your prompt Git Radar is highly customisable using a prompt format string. The 4 features @@ -226,6 +235,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 -- cgit v1.2.3 From 1a856774a1c0d0f6a9957046e90c1c24d253e6a0 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Thu, 15 Oct 2015 17:42:57 +0100 Subject: Fix tests broken by old regex string --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 6a9c630..52043d4 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -197,7 +197,7 @@ branch_ref() { } remote_branch_name() { - local localRef="\/$(branch_name)$" + local localRef="$(branch_name)" if [[ -n "$localRef" ]]; then local remote="$(git config --get-regexp "^branch\.$localRef\.remote" | awk '{print $2}')" if [[ -n $remote ]]; then -- cgit v1.2.3 From a0beb92f7f28fadb8255ee05765497eeb159795b Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Fri, 16 Oct 2015 11:43:00 +0100 Subject: That if statement wasn't doing what I thought it was --- radar-base.sh | 20 +++-- test-format-config.sh | 212 +++++++++++++++++++++++++------------------------- 2 files changed, 115 insertions(+), 117 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index 52043d4..9527343 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -198,19 +198,17 @@ branch_ref() { remote_branch_name() { local localRef="$(branch_name)" - if [[ -n "$localRef" ]]; then - local remote="$(git config --get-regexp "^branch\.$localRef\.remote" | awk '{print $2}')" - if [[ -n $remote ]]; then - local remoteBranch="$(git config --get-regexp "^branch\.${localRef}\.merge" | awk -F'/' '{print $NF}')" - if [[ -n $remoteBranch ]]; then - printf '%s/%s' $remote $remoteBranch - return 0 - else - return 1 - fi + local remote="$(git config --get-regexp "^branch\.$localRef\.remote" | awk '{print $2}')" + if [[ -n $remote ]]; then + local remoteBranch="$(git config --get-regexp "^branch\.${localRef}\.merge" | awk -F'/' '{print $NF}')" + if [[ -n $remoteBranch ]]; then + printf '%s/%s' $remote $remoteBranch + return 0 else - return 1 + return 1 fi + else + return 1 fi } diff --git a/test-format-config.sh b/test-format-config.sh index 5504ebc..72ac60d 100755 --- a/test-format-config.sh +++ b/test-format-config.sh @@ -124,111 +124,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 From 5bee2b0f959cd44cd636610d06d67f103fdbe37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Fri, 16 Oct 2015 09:52:50 +0200 Subject: Escape all forward slashes With out the 'g' flag only the first one will be replaced. This leads to errors with branches like wip/user/hotfix. --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 258e5b1..aeb0f41 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -517,7 +517,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 -- cgit v1.2.3 From b8797284031edbfd4c22f19f4878418cf4b2ec10 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Fri, 16 Oct 2015 11:31:21 -0700 Subject: Made changes recommeneded by @michaeldfallen in fetch.sh "if" now checks for $@ instead of just $1 in radar-base.sh there is now a parameter expansion on line 170 instead of the if statements. in git-radar, now there is a shift, and a regex check that the next value is a number. If the next value after --fetch_t is not a number, an error is echo'd and it resorts to the default behaviour of 5 minutes. --- fetch.sh | 2 +- git-radar | 15 +++++++++++++-- radar-base.sh | 7 +------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fetch.sh b/fetch.sh index a3fc571..877fa7b 100755 --- a/fetch.sh +++ b/fetch.sh @@ -10,7 +10,7 @@ dot="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; p source $dot/radar-base.sh -if [[ -z "$1" ]]; then +if [[ -z "$@" ]]; then fetch; else fetch $1; diff --git a/git-radar b/git-radar index c3f7aa3..a38f00f 100755 --- a/git-radar +++ b/git-radar @@ -100,8 +100,19 @@ while [[ $# > 0 ]];do # Custom fetch of whatever time interval the user wants if [[ "$command" == "--fetch_t" ]]; then - # Now $1 is the value of fetch_t - nohup $dot/fetch.sh $1 >/dev/null 2>&1 & + # Now $1 is the value for fetch_t + # If value is not a number produce an error + if ! [[ $1 =~ ^[0-9]+$ ]] ; then + echo "" + echo "Error: fetch_t did not receive a number" + echo "Defaulting to 5 min." + echo " " + nohup $dot/fetch.sh >/dev/null 2>&1 & + else + command="$1" + shift + nohup $dot/fetch.sh $command >/dev/null 2>&1 & + fi fi if [[ "$command" == "--zsh" ]]; then diff --git a/radar-base.sh b/radar-base.sh index ee5fa00..886a6e9 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -167,12 +167,7 @@ time_to_update() { } fetch() { - if [ -z "$1" ]; then - # Default 5 minutes - local timeToUpdate="$((5 * 60))" - else - local timeToUpdate="$1" - fi + local timeToUpdate = ${"$1":-"$((5 * 60))"} if time_to_update $timeToUpdate; then record_timestamp -- cgit v1.2.3 From ddb1e04e741bb6f1d8a159367c1bc123d387c87d Mon Sep 17 00:00:00 2001 From: Seth Mason Date: Fri, 16 Oct 2015 12:00:23 -0700 Subject: Remove a awk calls Turns out it had a bug when the branch name had a slash in it. --- radar-base.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index 9527343..653f980 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -198,9 +198,9 @@ branch_ref() { remote_branch_name() { local localRef="$(branch_name)" - local remote="$(git config --get-regexp "^branch\.$localRef\.remote" | awk '{print $2}')" + local remote="$(git config --get "branch.$localRef.remote")" if [[ -n $remote ]]; then - local remoteBranch="$(git config --get-regexp "^branch\.${localRef}\.merge" | awk -F'/' '{print $NF}')" + local remoteBranch="$(git config --get "branch.${localRef}.merge" | sed -e 's/^refs\/heads\///')" if [[ -n $remoteBranch ]]; then printf '%s/%s' $remote $remoteBranch return 0 -- cgit v1.2.3 From 3bdb43d9dad5766c23a34e438ad3fbd05823b6bd Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Fri, 16 Oct 2015 16:26:11 -0700 Subject: Fixed an error in my parameter subsitution. --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 886a6e9..d639fa0 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -167,7 +167,7 @@ time_to_update() { } fetch() { - local timeToUpdate = ${"$1":-"$((5 * 60))"} + local timeToUpdate=${1:-"$((5 * 60))"} if time_to_update $timeToUpdate; then record_timestamp -- cgit v1.2.3 From 8bef8d80648accd2806ad44e8db6e3aacd92d2e7 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:27:32 -0700 Subject: Custom Fetch time now uses a variable Set the variable GIT_RADAR_FETCH_TIME in a bashrc, zshrc or gitradarrc file to customize the fetch time. --- README.md | 20 +++++++++++++++----- fetch.sh | 6 +----- git-radar | 21 --------------------- radar-base.sh | 17 ++++++++++++++++- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index c54764f..4f65c9c 100644 --- a/README.md +++ b/README.md @@ -182,13 +182,23 @@ export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " ``` [(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution) -You may also choose to use the `--fetch_t` option to specify your own fetch -times. `--fetch` defaults to fetch automatically every 5 minutes. With -`--fetch_t ` you can choose how often to fetch. +You may also choose to fetch at a customized interval of time. To do so, add +this to your .bashrc, .zshrc: -eg. ```bash -export PS1="$PS1\$(git-radar --bash --fetch_t 30)" +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 diff --git a/fetch.sh b/fetch.sh index 877fa7b..37601e3 100755 --- a/fetch.sh +++ b/fetch.sh @@ -10,8 +10,4 @@ dot="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; p source $dot/radar-base.sh -if [[ -z "$@" ]]; then - fetch; -else - fetch $1; -fi +fetch; diff --git a/git-radar b/git-radar index a38f00f..07f0a0a 100755 --- a/git-radar +++ b/git-radar @@ -84,37 +84,16 @@ if [[ -z $@ ]]; then echo " end" echo "" echo " Same as the Bash but for fish." - echo "" - echo "Fetch_t example:" - echo " export PS1=\"\\W\\\$(git-radar --bash --fetch_t 45) \"" exit fi while [[ $# > 0 ]];do command="$1" shift - # Default fetch of 5 min if [[ "$command" == "--fetch" ]]; then nohup $dot/fetch.sh >/dev/null 2>&1 & fi - # Custom fetch of whatever time interval the user wants - if [[ "$command" == "--fetch_t" ]]; then - # Now $1 is the value for fetch_t - # If value is not a number produce an error - if ! [[ $1 =~ ^[0-9]+$ ]] ; then - echo "" - echo "Error: fetch_t did not receive a number" - echo "Defaulting to 5 min." - echo " " - nohup $dot/fetch.sh >/dev/null 2>&1 & - else - command="$1" - shift - nohup $dot/fetch.sh $command >/dev/null 2>&1 & - fi - fi - if [[ "$command" == "--zsh" ]]; then $dot/prompt.zsh $args fi diff --git a/radar-base.sh b/radar-base.sh index d639fa0..f9d834a 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -13,6 +13,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" @@ -167,7 +181,8 @@ time_to_update() { } fetch() { - local timeToUpdate=${1:-"$((5 * 60))"} + get_fetch_time + local timeToUpdate=${1:-$FETCH_TIME} if time_to_update $timeToUpdate; then record_timestamp -- cgit v1.2.3 From f52ce6c1b35edf7f35f20b6c10811ff6d978a688 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:30:17 -0700 Subject: Missed a fetch_t in the git_radar file to remove. --- git-radar | 1 - 1 file changed, 1 deletion(-) diff --git a/git-radar b/git-radar index 07f0a0a..ce11945 100755 --- a/git-radar +++ b/git-radar @@ -57,7 +57,6 @@ if [[ -z $@ ]]; then echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --fetch_t # Fetches your repo asynchronously in the background every seconds" echo " --zsh # Output prompt using Zsh style color characters" echo " --bash # Output prompt using Bash style color characters" echo " --fish # Output prompt using fish style color characters" -- cgit v1.2.3 From 51000c4213983fc2a72b039858112b3bb4c2b592 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:31:52 -0700 Subject: Moved comments back to original position. --- git-radar | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-radar b/git-radar index ce11945..9c8565f 100755 --- a/git-radar +++ b/git-radar @@ -56,10 +56,10 @@ if [[ -z $@ ]]; then echo "usage:" echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" - echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --zsh # Output prompt using Zsh style color characters" - echo " --bash # Output prompt using Bash style color characters" - echo " --fish # Output prompt using fish style color characters" + echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" + echo " --zsh # Output prompt using Zsh style color characters" + echo " --bash # Output prompt using Bash style color characters" + echo " --fish # Output prompt using fish style color characters" echo "" echo "Bash example:" echo " export PS1=\"\\W\\\$(git-radar --bash --fetch) \"" -- cgit v1.2.3 From 40445543f10f4e10cc13ea8a9e4ba0a79cb200db Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 23:07:31 -0700 Subject: Since a number is no longer taken after --fetch_t we can remove the parameter substitution that has been removed in this commit. --- radar-base.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index f9d834a..538d593 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -181,10 +181,10 @@ time_to_update() { } fetch() { + # Gives $FETCH_TIME a value get_fetch_time - local timeToUpdate=${1:-$FETCH_TIME} - if time_to_update $timeToUpdate; then + if time_to_update $FETCH_TIME; then record_timestamp git fetch --quiet > /dev/null 2>&1 fi -- cgit v1.2.3 From 984ff133d360222906ff20f7431be9a70a212539 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 21 Oct 2015 11:59:16 +0100 Subject: Fix tests broken by FETCH_TIME now being pushed in --- radar-base.sh | 3 ++- test-directories.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 0f4a35a..099debd 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -183,9 +183,10 @@ time_now() { } time_to_update() { + last_time_updated="${1:-$FETCH_TIME}" if is_repo; then local timesincelastupdate="$(($(time_now) - $(timestamp)))" - if (( $timesincelastupdate > $1 )); then + if (( $timesincelastupdate > $last_time_updated )); then # time to update return 0 (which is true) return 0 else diff --git a/test-directories.sh b/test-directories.sh index 86a441e..5dde303 100755 --- a/test-directories.sh +++ b/test-directories.sh @@ -63,12 +63,14 @@ test_record_timestamp_in_repo() { test_time_to_update_when_timestamp_is_old() { cd $scriptDir + FETCH_TIME="$((5 * 60))" # Fetch every 5 mins touch -A "-010000" "$(dot_git)/lastupdatetime" assertTrue time_to_update } test_not_time_to_update_when_just_recorded() { cd $scriptDir + FETCH_TIME="$((5 * 60))" # Fetch every 5 mins record_timestamp assertFalse time_to_update } @@ -77,6 +79,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 -- cgit v1.2.3 From f085dc8445319c4282b67ff3698d7d7b5b319d3f Mon Sep 17 00:00:00 2001 From: Colin Scott-Fleming Date: Sun, 1 Nov 2015 11:04:20 -0700 Subject: bury error output from remote branch lookup closes #88 closes #86 --- radar-base.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index 099debd..517a6ce 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -249,7 +249,7 @@ remote_branch_name() { 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 @@ -258,7 +258,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 -- cgit v1.2.3 From 8b1ffb6f7fb99865a9aadc9afbe9acb6977c5b3c Mon Sep 17 00:00:00 2001 From: Matthew Hillman Date: Fri, 6 Nov 2015 09:39:51 -0600 Subject: Fix for bad characters showing in the stash status in OS X --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index 517a6ce..f45669e 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -539,7 +539,7 @@ stashed_status() { stash_status() { local number_stashes="$(stashed_status)" if [ $number_stashes -gt 0 ]; then - printf $PRINT_F_OPTION "$number_stashes$COLOR_STASH≡$RESET_COLOR_STASH" + printf $PRINT_F_OPTION "$number_stashes${COLOR_STASH}≡$RESET_COLOR_STASH" fi } -- cgit v1.2.3 From 22144d3c227adba425f822700dc2559301ebdeb2 Mon Sep 17 00:00:00 2001 From: Matthew Hillman Date: Mon, 9 Nov 2015 10:04:39 -0600 Subject: =?UTF-8?q?Surround=20all=20variables=20on=20stash=5Fstatus()?= =?UTF-8?q?=E2=80=99s=20return=20line=20with=20{}=20for=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index f45669e..f4bbc13 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -539,7 +539,7 @@ stashed_status() { stash_status() { local number_stashes="$(stashed_status)" if [ $number_stashes -gt 0 ]; then - printf $PRINT_F_OPTION "$number_stashes${COLOR_STASH}≡$RESET_COLOR_STASH" + printf $PRINT_F_OPTION "${number_stashes}${COLOR_STASH}≡${RESET_COLOR_STASH}" fi } -- cgit v1.2.3 From dce2a1b3859ebb052c220255dc1b7e130a272ace Mon Sep 17 00:00:00 2001 From: "P.Kernevez" Date: Tue, 5 Jan 2016 23:48:24 +0100 Subject: Remove the '\n' that put the cursor on a new line (prompt on 2 lines instead of one) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e84317..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 -- cgit v1.2.3 From b2e8e05c92471fab6fb06892d854ceb2ae203b9d Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Wed, 20 Jan 2016 13:13:54 -0800 Subject: Resolve issue #98 radar-base.sh now checks to see if the current directory is a .git directory. If it is, it skips the git stash part. --- radar-base.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/radar-base.sh b/radar-base.sh index f4bbc13..f690f24 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -63,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() { @@ -90,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}%}" @@ -536,10 +536,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() { + test "$(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 } -- cgit v1.2.3 From c67d6bcd88c9073bc072af1cb13d7bfa85cbbbb0 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 3 Feb 2016 11:05:31 +0000 Subject: Fix '= not found' issue --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index f690f24..a9e3a7f 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -537,7 +537,7 @@ stashed_status() { } is_cwd_a_dot_git_directory() { - test "$(basename $PWD)" == ".git"; return $? + [[ "$(basename $PWD)" == ".git" ]]; return $? } stash_status() { -- cgit v1.2.3 From 16162c5127bba49ede35e789a302c86a068c64a3 Mon Sep 17 00:00:00 2001 From: bogem Date: Fri, 23 Sep 2016 15:22:55 +0200 Subject: Add lightweight version to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2f4e39f..91f87cd 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ last few years. Maybe it can help you too. - [Colouring the remote commits status](#colouring-the-remote-commits-status) - [Colouring the file changes status](#colouring-the-file-changes-status) - [License](#license) +- [Links](#links) ## Installation @@ -557,6 +558,10 @@ Git Radar is licensed under the MIT license. See [LICENSE] for the full license text. +## Links + +* [mini-git-radar](https://github.com/bogem/mini-git-radar) - lightweight version of git-radar. Only for macOS and bash/fish. + [LICENSE]: https://github.com/michaeldfallen/git-radar/blob/master/LICENSE [git:(master) 1≡]: https://raw.githubusercontent.com/michaeldfallen/git-radar/master/images/stash.png [git:(master) 3A]: https://raw.githubusercontent.com/michaeldfallen/git-radar/master/images/untracked.png -- cgit v1.2.3 From 2ac25e3d1047cdf19f15bc894ff39449b83d65d4 Mon Sep 17 00:00:00 2001 From: crf204 Date: Sun, 4 Dec 2016 18:53:32 -0500 Subject: fix for basename: extra operand warning --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radar-base.sh b/radar-base.sh index a9e3a7f..61503fd 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -537,7 +537,7 @@ stashed_status() { } is_cwd_a_dot_git_directory() { - [[ "$(basename $PWD)" == ".git" ]]; return $? + [[ "$(basename "$PWD")" == ".git" ]]; return $? } stash_status() { -- cgit v1.2.3