[Update] Exit with fancy error when branch is empty

master
andryyy 2019-07-08 18:45:57 +02:00
parent 59ca12a7e4
commit f0e51a39d7
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
1 changed files with 10 additions and 9 deletions

View File

@ -26,15 +26,16 @@ DATE=$(date +%Y-%m-%d_%H_%M_%S)
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
function prefetch_images() { function prefetch_images() {
while read image; do [[ -z ${BRANCH} ]] && { echo -e "\e[33m\nUnknown branch...\e[0m"; exit 1; }
RET_C=0 while read image; do
until docker pull ${image}; do RET_C=0
RET_C=$((RET_C + 1)) until docker pull ${image}; do
echo -e "\e[33m\nError pulling $image, retrying...\e[0m" RET_C=$((RET_C + 1))
[ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; } echo -e "\e[33m\nError pulling $image, retrying...\e[0m"
sleep 1 [ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; }
done sleep 1
done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }') done
done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }')
} }
docker_garbage() { docker_garbage() {