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 . &&