diff options
author | Michael Allen <michael@michaelallen.io> | 2015-10-27 10:45:42 +0000 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-10-27 10:45:42 +0000 |
commit | 47addd8b811e77f3be815fea56bcaeddd89edea0 (patch) | |
tree | 611ef993dd3c37aeb510495ce58ddcb41563805c /radar-base.sh | |
parent | 934f6fd5b317476e7680bfd07dc2b685b5c37c4d (diff) | |
parent | 225de5490a49e92ea34326226308159e93b6b80d (diff) | |
download | git-sonar-0.5.tar.gz git-sonar-0.5.zip |
Merge pull request #70 from hallzy/masterv0.5
Added feature that let's you specify how often to fetch
Diffstat (limited to 'radar-base.sh')
-rwxr-xr-x | radar-base.sh | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/radar-base.sh b/radar-base.sh index f11d3ae..099debd 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" @@ -169,10 +183,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 @@ -185,7 +199,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 |