]> git.parisson.com Git - docker-django-scripts.git/commitdiff
Add hard reset option to update and upgrade
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Aug 2018 15:30:24 +0000 (17:30 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Aug 2018 15:30:24 +0000 (17:30 +0200)
prod/update.sh
prod/upgrade.sh

index 0594c7eb0dc05065340b3a8925f0201d57203a4b..39651100723ee2ff05403eb6c3e180f6d69e2a4a 100755 (executable)
 
 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)'
index 8f88ec9b0d499ae3644ebddd270ec18e9a0f959f..6ddb799e7b77e329feb99e54d77b9f1b498a3cbc 100755 (executable)
@@ -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
             ;;