Separated cloneRepo into 3 functions

This commit is contained in:
PWall 2023-05-10 11:19:07 +02:00
parent 9432cdfed9
commit a2e083e01c

View File

@ -38,10 +38,11 @@ setupGit() {
git config --global user.name "$USER_NAME"
}
cloneRepo() {
{
cloneSimple() {
git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR"
} || {
}
cloneCreateBranch() {
if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ]
then
# Default branch of the repository is cloned. Later on the required branch
@ -50,13 +51,18 @@ cloneRepo() {
else
false
fi
} || {
}
cloneError() {
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::(Note that if they exist USER_NAME and API_TOKEN is redacted by GitHub)"
echo "::error::Please verify that the target repository exist AND that it contains the destination branch name, and is accesible by the API_TOKEN_GITHUB OR SSH_DEPLOY_KEY"
exit 1
}
}
cloneRepo() {
cloneSimple || cloneCreateBranch || cloneError
}
checkSource() {