From: Guillaume Pellerin Date: Thu, 23 Aug 2018 15:30:24 +0000 (+0200) Subject: Add hard reset option to update and upgrade X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=531645508807efca744dc4f6b5f2a28ec7ab8b5b;p=docker-django-scripts.git Add hard reset option to update and upgrade --- diff --git a/prod/update.sh b/prod/update.sh index 0594c7e..3965110 100755 --- a/prod/update.sh +++ b/prod/update.sh @@ -10,11 +10,36 @@ cd "$(dirname "$0")"/../../ +function usage() { + echo "update the Mezzo instance and all submodules with various options" + echo "" + echo "./update.sh" + echo " -h --help" + echo " -hr --hard-reset : hard reset the main project and submodules before update" + echo "" +} + +while [ "$1" != "" ]; do + PARAM=`echo $1 | awk -F= '{print $1}'` + VALUE=`echo $1 | awk -F= '{print $2}'` + case $PARAM in + -h | --help) + usage + exit + ;; + -hr | --hard-reset) + git reset --hard + git submodule foreach --recursive 'git reset --hard' + ;; + esac + shift +done + # Update main project git pull +# Get the current branch curr_branch=$(git symbolic-ref --short HEAD) - echo $curr_branch if [ $curr_branch != "master" ] && [ $curr_branch != "dev" ]; then @@ -23,9 +48,12 @@ fi # checkout new submodule git submodule update --init + # Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules git submodule sync + # Checkout all submodules on right branches specified in .gitmodules, by default the branch is master git submodule foreach --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' + # Pull all submodules on right branches specified in .gitmodules, by default the branch is master git submodule foreach --recursive 'git pull origin $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' diff --git a/prod/upgrade.sh b/prod/upgrade.sh index 8f88ec9..6ddb799 100755 --- a/prod/upgrade.sh +++ b/prod/upgrade.sh @@ -8,6 +8,7 @@ function usage() { echo "./upgrade.sh" echo " -h --help" echo " -u --update : update main project and submodules" + echo " -uhr --update-hard-reset : update and hard reset main project and submodules" echo " -m --migrate : apply migrations" echo " -f --front : build frontend" echo " -d --doc : build documentation" @@ -28,6 +29,9 @@ while [ "$1" != "" ]; do -u | --update) ./bin/prod/update.sh ;; + -uhr | --update-hard-reset) + ./bin/prod/update.sh -hr + ;; -m | --migrate) docker-compose run app python /srv/app/manage.py migrate ;;