From c8e14e7a1efc1cae939b75545e82282c03e515b9 Mon Sep 17 00:00:00 2001
From: Quentin Duchemin <quentinduchemin@tuta.io>
Date: Thu, 30 Jan 2020 00:28:20 +0100
Subject: [PATCH] [CI] Handy colors and careful checks in test script

---
 docker_test.sh | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/docker_test.sh b/docker_test.sh
index 9b8dab63..c8b17fa2 100755
--- a/docker_test.sh
+++ b/docker_test.sh
@@ -1,6 +1,8 @@
-#!/bin/sh
+#!/bin/bash
 
-function usage() {
+set -e
+
+usage() {
   echo -e "usage:\t$0 DIRECTORY, e.g. $0 pica-mattermost"
   echo -e "\tDIRECTORY : name of the directory containing docker-compose.yml\n"
   echo "This script simulates the first launch of a service : it will recreate all existing volumes for the service"
@@ -30,14 +32,21 @@ fi
 # Go to the folder of the service which will be tested
 cd "$1"
 
-echo -e "Starting procedure for $1...\n"
+echo -e "Starting procedure for \033[31m$1\e[0m..."
 echo -e "\n==== Stop and remove existing containers ===="
 docker-compose down
 
-echo "==== Reset and pull Dockerfiles repository ===="
-echo "Using branch" $(git branch --show-current)
-git reset --hard
-git pull
+echo -e "\n==== RESET HARD and pull Dockerfiles repository ===="
+echo -e "Using branch \033[31m $(git rev-parse --abbrev-ref HEAD)\e[0m, is this correct ? [y/N]"
+read ans
+
+if [ $ans == "y" ]; then
+  git reset --hard
+  git pull
+else
+  echo "Aborting."
+  exit 0
+fi
 
 echo -e "\n==== Remove and re-create named external volumes ===="
 for v in $(docker-compose config --volumes); do
@@ -50,7 +59,7 @@ docker-compose pull
 
 echo -e "\n==== Replace production URL with testing URL in all files ===="
 for f in $(grep -l -r ".picasoft.net" .); do
-  echo -e "\t*" ${f}
+  echo -e "\tFound in" ${f}
   sed -i "s/.picasoft.net/.test.picasoft.net/g" ${f}
 done
 
-- 
GitLab