From e7314057a0d0708b3a5f1f3017fa00198e5b74b3 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Wed, 8 Dec 2021 23:55:47 +0100 Subject: [PATCH] Fix deleting of files when TARGET_DIRECTORY is not specified --- entrypoint.sh | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 76d6016..0665382 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,25 +41,20 @@ TEMP_DIR=$(mktemp -d) # including "." and with the exception of ".git/" mv "$CLONE_DIR/.git" "$TEMP_DIR/.git" -if [ -n "$TARGET_DIRECTORY" ] -then - echo "[+] Checking if $TARGET_DIRECTORY exist in git repo $DESTINATION_REPOSITORY_NAME" +# $TARGET_DIRECTORY is '' by default +ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/" - # Remove contents of target directory and create a new empty one - if [ -d "$CLONE_DIR/$TARGET_DIRECTORY/" ] - then - echo "[+] Deleting files from $TARGET_DIRECTORY in git repo $DESTINATION_REPOSITORY_NAME" - rm -R "$CLONE_DIR/$TARGET_DIRECTORY/" - fi - echo "[+] Creating $TARGET_DIRECTORY if it does not already exist" - mkdir -p "$CLONE_DIR/$TARGET_DIRECTORY" +echo "[+] Deleting $ABSOLUTE_TARGET_DIRECTORY" +rm -rf "$ABSOLUTE_TARGET_DIRECTORY" - echo "[+] Listing Current Directory Location" - ls -al +echo "[+] Creating (now empty) $ABSOLUTE_TARGET_DIRECTORY" +mkdir -p "$ABSOLUTE_TARGET_DIRECTORY" - echo "[+] Listing root Location" - ls -al / -fi +echo "[+] Listing Current Directory Location" +ls -al + +echo "[+] Listing root Location" +ls -al / mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"