From cbe757f8d8b380dd2b3ceec5a80fbcd61f1f3107 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Mon, 1 May 2023 00:03:52 +0200 Subject: [PATCH] Change indentation, add comment, use "git switch -c" instead of "git checkout -b" --- entrypoint.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bacb784..82048df 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -72,11 +72,14 @@ git config --global user.name "$USER_NAME" { git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR" } || { - if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = 'true' ] ; then - git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR" - else - false - fi + if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ] + then + # Default branch of the repository is cloned. Later on the required branch + # will be created + git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR" + else + false + fi } || { echo "::error::Could not clone the destination repository. Command:" echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR" @@ -145,8 +148,9 @@ echo "[+] Set directory is safe ($CLONE_DIR)" git config --global --add safe.directory "$CLONE_DIR" -if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = 'true' ] ; then - git checkout -b "$TARGET_BRANCH" +if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ] +then + git switch -c "$TARGET_BRANCH" fi echo "[+] Adding git commit"