Skip to content

Commit b2e2c48

Browse files
committed
Fix error if create-target-branch-if-needed is used and the target branch already existed
1 parent d63a102 commit b2e2c48

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

entrypoint.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ git config --global --add safe.directory "$CLONE_DIR"
149149
if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ]
150150
then
151151
echo "[+] Switch to the TARGET_BRANCH"
152-
git switch -c "$TARGET_BRANCH"
152+
# || true: if the $TARGET_BRANCH already existed in the destination repo:
153+
# it is already the current branch and it cannot be switched to
154+
# (it's not needed)
155+
# If the branch did not exist: it switches (creating) the branch
156+
git switch -c "$TARGET_BRANCH" || true
153157
fi
154158

155159
echo "[+] Adding git commit"

0 commit comments

Comments
 (0)