From b2e2c48ca5e3705f348a05372f4d77356d13bd50 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Fri, 19 May 2023 16:47:16 +0200 Subject: [PATCH] Fix error if create-target-branch-if-needed is used and the target branch already existed --- entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1694283..b462503 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -149,7 +149,11 @@ git config --global --add safe.directory "$CLONE_DIR" if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ] then echo "[+] Switch to the TARGET_BRANCH" - git switch -c "$TARGET_BRANCH" + # || true: if the $TARGET_BRANCH already existed in the destination repo: + # it is already the current branch and it cannot be switched to + # (it's not needed) + # If the branch did not exist: it switches (creating) the branch + git switch -c "$TARGET_BRANCH" || true fi echo "[+] Adding git commit"