From 7d24153945948d78c1ef4b2e12050233fbe2e65e Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 22 Nov 2021 10:32:44 +0100 Subject: [PATCH] new: [gogocarto] don't fail on improper source code directory Signed-off-by: Valentin Lab --- gogocarto/lib/common | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gogocarto/lib/common b/gogocarto/lib/common index b5da873..0d61c33 100644 --- a/gogocarto/lib/common +++ b/gogocarto/lib/common @@ -8,13 +8,13 @@ GOGOCARTO_URL=https://docker.0k.io/downloads/gogocarto-"${GOGOCARTO_RELEASE}".ta gogocarto:init() { current_version="" - if [ -d "${GOGOCARTO_CODE}" ]; then - current_version=$(cat "${GOGOCARTO_CODE}"/.version) || { - err "Couldn't find ${GOGOCARTO_CODE}/.version file." - echo " Your config dir is in a broken state." >&2 - return 1 - } - else + if [ -e "${GOGOCARTO_CODE}/.version" ]; then + current_version="$(cat "${GOGOCARTO_CODE}/.version")" || return 1 + fi + + ## Note: previous content will be removed, if not in `.git` and no + ## version matching current one + if ! [ -d "${GOGOCARTO_CODE}/.git" ]; then mkdir -p "${GOGOCARTO_CODE}" && cd "${GOGOCARTO_CODE}" && git init . &&