Better handling of the git clone error

This commit is contained in:
Carles Pina i Estany 2021-12-15 00:09:49 +00:00
parent 331033bc0f
commit 23869efe3d

View File

@ -33,17 +33,15 @@ echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME"
git config --global user.email "$USER_EMAIL" git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME" git config --global user.name "$USER_NAME"
{
git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR"
GIT_CLONE_EXIT_CODE=$? } || {
echo "::error::Could not clone the destination repository. Command:"
if [ "$GIT_CLONE_EXIT_CODE" != 0 ]
then
echo "::error::Could not clone the destination repository. Tried with:"
echo "::error::git clone --single-branch --branch $TARGET_BRANCH https://$USER_NAME:the_api_token@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git $CLONE_DIR" echo "::error::git clone --single-branch --branch $TARGET_BRANCH https://$USER_NAME:the_api_token@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git $CLONE_DIR"
echo "::error::Please verify that the branch $TARGET_BRANCH exist in the target repository and that the repository exist and is accessible by your API_TOKEN_GITHUB" echo "::error::Please verify that the branch $TARGET_BRANCH exist in the target repository and that the repository exist and is accessible by your API_TOKEN_GITHUB"
exit 1 exit 1
fi
}
ls -la "$CLONE_DIR" ls -la "$CLONE_DIR"
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)