summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-02-23 16:31:38 +0000
committerMichael Allen <michael@michaelallen.io>2015-02-23 16:34:49 +0000
commit0e5f04c68674f5f775b0973fa8b2bde4ff1eab4f (patch)
tree0397af8250b36bcae593aa16f613dd4f9519a0b3
parent85867b8e5be3bed7b79e7711a3d1bed2327f1188 (diff)
downloadgit-sonar-0e5f04c68674f5f775b0973fa8b2bde4ff1eab4f.tar.gz
git-sonar-0e5f04c68674f5f775b0973fa8b2bde4ff1eab4f.zip
fixed bad math and added recording the timestamp when we fetch
-rwxr-xr-xgit-base.sh11
-rwxr-xr-xtest-directories.sh1
2 files changed, 4 insertions, 8 deletions
diff --git a/git-base.sh b/git-base.sh
index 41e8833..7024161 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -62,7 +62,7 @@ record_timestamp() {
timestamp() {
if is_repo; then
- echo "$(stat -f%m "$(dot_git)/lastupdatetime" || echo 0)"
+ echo "$(stat -f%m "$(dot_git)/lastupdatetime" || echo "0")"
fi
}
@@ -74,7 +74,7 @@ time_to_update() {
if is_repo; then
local timesincelastupdate="$(($(time_now) - $(timestamp)))"
local fiveminutes="$((5 * 60))"
- if (( "$timesincelastupdate" > "$fiveminutes" )); then
+ if (( $timesincelastupdate > $fiveminutes )); then
# time to update return 0 (which is true)
return 0
else
@@ -87,19 +87,14 @@ time_to_update() {
}
fetch_async() {
- local debug="$1"
if time_to_update; then
- debug_print $debug "Starting fetch"
+ record_timestamp
fetch $debug &
- else
- debug_print $debug "Didn't fetch"
fi
}
fetch() {
- local debug="$1"
git fetch
- debug_print $debug "Finished fetch"
}
commit_short_sha() {
diff --git a/test-directories.sh b/test-directories.sh
index 1520ffb..e9b6d07 100755
--- a/test-directories.sh
+++ b/test-directories.sh
@@ -77,6 +77,7 @@ test_time_to_update_when_no_timestamp() {
cd_to_tmp
git init --quiet
+ time_to_update
assertTrue time_to_update
rm_tmp