Another attempt on making target branch creation actually work

This commit is contained in:
martin 2022-12-19 20:31:38 -08:00
parent 4caaae456b
commit a9444e55cd

View File

@ -57,6 +57,7 @@ fi
CLONE_DIR=$(mktemp -d) CLONE_DIR=$(mktemp -d)
new_target_branch=0
echo "[+] Git version" echo "[+] Git version"
git --version git --version
@ -69,7 +70,7 @@ git config --global --add safe.directory /github/workspace
if ! git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR"; then if ! git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR"; then
if ${CREATE_TARGET_BRANCH} && git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR"; then if ${CREATE_TARGET_BRANCH} && git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR"; then
echo "[+] Creating target branch ${TARGET_BRANCH}" new_target_branch=1
else else
echo "::error::Could not clone the destination repository. Command:" echo "::error::Could not clone the destination repository. Command:"
echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR" echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR"
@ -138,6 +139,12 @@ echo "[+] Set directory is safe ($CLONE_DIR)"
# TODO: review before releasing it as a version # TODO: review before releasing it as a version
git config --global --add safe.directory "$CLONE_DIR" git config --global --add safe.directory "$CLONE_DIR"
if [ ${new_target_branch} -ne 0 ]; then
echo "[+] Creating target branch ${TARGET_BRANCH}"
git branch ${TARGET_BRANCH}
git switch b1
fi
echo "[+] Adding git commit" echo "[+] Adding git commit"
git add . git add .