aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schramm <tobleminer@gmail.com>2018-06-30 19:44:11 +0200
committerTobias Schramm <tobleminer@gmail.com>2018-06-30 20:36:25 +0200
commit85abac37cc2b58f8c521dd7189be7dfd2355da5f (patch)
treebbbb070ee24d81de0e6477074530f897a469b3bf
parenta82b4d577be0c90fbff7b0b29c590b2bf1e1f96d (diff)
Enhance robustness of revision checking
[skip ci]
-rwxr-xr-xupdate-git.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/update-git.sh b/update-git.sh
index 31966ca..762fd79 100755
--- a/update-git.sh
+++ b/update-git.sh
@@ -15,7 +15,7 @@ function update() {
exit 0
fi
- REMOTE_REF=$(git ls-remote -qht "$GLUON_GIT" | grep "$GLUON_BRANCH" | cut -f1)
+ REMOTE_REFS="$(git ls-remote -qht "$GLUON_GIT" | grep "$GLUON_BRANCH" | cut -f1)"
cd gluon
set +e
@@ -24,8 +24,21 @@ function update() {
set -e
cd ..
- if [[ $GIT_EXIT -ne 0 || $REMOTE_REF != "$LOCAL_REF" ]]; then
- echo "$REMOTE_REF != $LOCAL_REF, updating"
+ if [[ $GIT_EXIT -ne 0 ]]; then
+ echo "Local repo damaged, forcing update"
update
+ exit 0
fi
+
+ # There can be multiple objects describing the same state, we need to check them all
+ for ref in $REMOTE_REFS; do
+ echo "Checking $ref == $LOCAL_REF"
+ if [[ "$ref" == "$LOCAL_REF" ]]; then
+ echo "Local repo is up to date"
+ exit 0
+ fi
+ done
+
+ echo "Local state does not reflect latest remote state, updating"
+ update
)