From 5b3bd806346f00395b7896a7a00d37166e2c80e6 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 9 Oct 2023 15:57:02 +0200 Subject: [PATCH] fix(git-clone): change to work with volumes fixes #79 (#80) * fix(git-clone): change to work with volumes fixes #79 * Update git-clone/run.sh Co-authored-by: Kyle Carberry --------- Co-authored-by: Muhammad Atif Ali Co-authored-by: Kyle Carberry --- git-clone/run.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/git-clone/run.sh b/git-clone/run.sh index 1fee8da..6eb1ff5 100755 --- a/git-clone/run.sh +++ b/git-clone/run.sh @@ -23,16 +23,19 @@ if ! command -v git >/dev/null; then exit 1 fi -# Check if the directory exists... +# Check if the directory for the cloning exists +# and if not, create it if [ ! -d "$CLONE_PATH" ]; then echo "Creating directory $CLONE_PATH..." mkdir -p "$CLONE_PATH" +fi + +# Check if the directory is empty +# and if it is, clone the repo, otherwise skip cloning +if [ -z "$(ls -A "$CLONE_PATH")" ]; then + echo "Cloning $REPO_URL to $CLONE_PATH..." + git clone "$REPO_URL" "$CLONE_PATH" else - echo "$CLONE_PATH already exists, skipping clone!" + echo "$CLONE_PATH already exists and isn't empty, skipping clone!" exit 0 fi - -# Clone the repository... -echo "Cloning $REPO_URL to $CLONE_PATH..." -git clone "$REPO_URL" "$CLONE_PATH" -