From 1af0c9b1f55594c24fa6d53dd4752c3648095e09 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 3 May 2023 08:37:41 +0200 Subject: [PATCH] chg: dev: [gogocarto] de-indent code !minor --- gogocarto/lib/common | 52 ++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/gogocarto/lib/common b/gogocarto/lib/common index 0adfbdd..b31b040 100644 --- a/gogocarto/lib/common +++ b/gogocarto/lib/common @@ -24,32 +24,36 @@ gogocarto:init() { return 1 } fi - if [ "$current_version" != "$GOGOCARTO_RELEASE" ]; then - cd "${GOGOCARTO_CODE}" || return 1 - if [ -d "$PWD"/.git ]; then - rm -rf "$PWD"/* "$PWD"/{.version,.env} || return 1 - else - err "Can't find the '.git' directory in ${GOGOCARTO_CODE}." - return 1 - fi - curl -L "$GOGOCARTO_URL" | tar xj || { - err "Couldn't download $GOGOCARTO_URL." - return 1 - } - echo "$GOGOCARTO_RELEASE" > .version - git add -A . || { - err "'git add -A .' in '${GOGOCARTO_CODE}' failed." + + ## Check if we need to upgrade code. + if [ "$current_version" == "$GOGOCARTO_RELEASE" ]; then + return 0 + fi + + cd "${GOGOCARTO_CODE}" || return 1 + if [ -d "$PWD"/.git ]; then + rm -rf "$PWD"/* "$PWD"/{.version,.env} || return 1 + else + err "Can't find the '.git' directory in ${GOGOCARTO_CODE}." + return 1 + fi + curl -L "$GOGOCARTO_URL" | tar xj || { + err "Couldn't download $GOGOCARTO_URL." + return 1 + } + echo "$GOGOCARTO_RELEASE" > .version + git add -A . || { + err "'git add -A .' in '${GOGOCARTO_CODE}' failed." + return 1 + } + if git diff --staged -s --exit-code; then + info "No differences with last saved version." + else + git commit -m "Release $GOGOCARTO_RELEASE" || { + err "'git commit' failed." return 1 } - if git diff --staged -s --exit-code; then - info "No differences with last saved version." - else - git commit -m "Release $GOGOCARTO_RELEASE" || { - err "'git commit' failed." - return 1 - } - rm -rf "$SERVICE_DATASTORE/var/cache/gogocarto/"* - fi + rm -rf "$SERVICE_DATASTORE/var/cache/gogocarto/"* fi }