From: Sam Date: Tue, 10 Mar 2015 04:47:55 +0000 (+1100) Subject: re-exec self if we are out of date X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=098533cb0b2bbea0e55ead77f7bc1b8c668965c0;p=discourse_docker.git re-exec self if we are out of date --- diff --git a/launcher b/launcher index a573f5d..cce035d 100755 --- a/launcher +++ b/launcher @@ -557,8 +557,32 @@ case "$command" in rebuild) if [ "$(git symbolic-ref --short HEAD)" == "master" ]; then - echo "Updating discourse docker" - git pull || (echo 'failed to update' && exit 1) + echo "Ensuring discourse docker is up to date" + + git remote update + + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse @{u}) + BASE=$(git merge-base @ @{u}) + + if [ $LOCAL = $REMOTE ]; then + echo "Discourse Docker is up-to-date" + + elif [ $LOCAL = $BASE ]; then + echo "Updating Discourse Docker" + git pull || (echo 'failed to update' && exit 1) + exec /bin/bash $0 $@ + + elif [ $REMOTE = $BASE ]; then + echo "Your version of Discourse Docker is ahead of origin" + + else + echo "Discourse Docker has diverged source" + + fi + + exit + fi if [ -e $cidfile ] then