From 499df0126285cc554eada64917a2ffa5266db9fd Mon Sep 17 00:00:00 2001 From: Drew Short Date: Sun, 13 Sep 2015 15:27:51 -0500 Subject: [PATCH] Starting on some error checking inside the update script. Don't want it to blow up if it can't reach out. --- scripts/.update_dotfiles.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/.update_dotfiles.sh b/scripts/.update_dotfiles.sh index 2980564..b3ddcc4 100755 --- a/scripts/.update_dotfiles.sh +++ b/scripts/.update_dotfiles.sh @@ -5,7 +5,8 @@ opwd=$PWD cd @GIT_DIR@ # Update the status of the origin -git remote update origin +# No need to print the result, this should be silent and invisible +git remote update origin 1>/dev/null # Check if we need to update at all # Kindly borrowed from http://stackoverflow.com/questions/3258243/git-check-if-pull-needed @@ -13,14 +14,18 @@ LOCAL=$(git rev-parse @) REMOTE=$(git rev-parse @{u}) BASE=$(git merge-base @ @{u}) +# Exit if for some reason we don't get info from the remote. +if [ -z "$REMOTE" ]; then + exit 0 +fi + # All good, no need to update if [ $LOCAL = $REMOTE ]; then - echo "Up-to-date" + # No need to declare anything while we do this exit 0 # Time to update to the remote branch elif [ $LOCAL = $BASE ]; then - echo "Need to pull" - echo 'Updating dotfiles' + echo "Updating dotfiles in: $PWD" git checkout master git pull git submodule update