From f0e51a39d733a662b9da183e7f44855e59523fa1 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 8 Jul 2019 18:45:57 +0200 Subject: [PATCH] [Update] Exit with fancy error when branch is empty --- update.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/update.sh b/update.sh index ecea24f4..050ff002 100755 --- a/update.sh +++ b/update.sh @@ -26,15 +26,16 @@ DATE=$(date +%Y-%m-%d_%H_%M_%S) BRANCH=$(git rev-parse --abbrev-ref HEAD) function prefetch_images() { -while read image; do - RET_C=0 - until docker pull ${image}; do - RET_C=$((RET_C + 1)) - echo -e "\e[33m\nError pulling $image, retrying...\e[0m" - [ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; } - sleep 1 - done -done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }') + [[ -z ${BRANCH} ]] && { echo -e "\e[33m\nUnknown branch...\e[0m"; exit 1; } + while read image; do + RET_C=0 + until docker pull ${image}; do + RET_C=$((RET_C + 1)) + echo -e "\e[33m\nError pulling $image, retrying...\e[0m" + [ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; } + sleep 1 + done + done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }') } docker_garbage() {