---
# System prepended metadata

title: Set Default Git Clone Protocol to https in case it is not specified

---

'''
#!/bin/bash

# Set Default Git Clone Protocol to https in case it is not specified
if [ ! ${GIT_PCN_CLONE_PROTO} ] ;
then
    GIT_PCN_CLONE_PROTO=https
fi

# Set the Default Tag to be cloned for build toolchain tools repo
if [ ! ${GIT_PCN_TOOLCHAIN_TAG} ] ;
then
    GIT_PCN_TOOLCHAIN_TAG=REL_1_1_1
fi

# Set the Default Tag to be cloned for build dependency third-party libs repo
if [ ! ${GIT_PCN_THIRDPARTY_TAG} ] ;
then
    GIT_PCN_THIRDPARTY_TAG=REL_1_1_0
fi

# Set the Default Tag to be cloned for build dependency pcn-buildtests  repo
if [ ! ${GIT_PCN_BUILDTESTS_TAG} ] ;
then
    GIT_PCN_BUILDTESTS_TAG=REL_1_0_0
fi
TARGET=gcc840_ub
COMPILER_TOOLS="toolchains/${TARGET}/${GIT_PCN_TOOLCHAIN_TAG}"
THIRDPARTY_ROOT="3p_libs/${TARGET}/${GIT_PCN_THIRDPARTY_TAG}"
BUILDTESTS_ROOT="pcn-buildtest"

git config --global url."https://${TOKEN_USER}:${PRIVATE_TOKEN}@gitlab.private.aws.cradlepointecm.com/".insteadOf "https://gitlab.private.aws.cradlepointecm.com/"

if [ "${GIT_PCN_CLONE_PROTO}" == "https" ] ; then
    echo "Cloning of build dependencies selected over https"
    GIT_TOOLCHAIN_CLONE_URL="https://gitlab.private.aws.cradlepointecm.com/pcn/pcn-tools-${TARGET}.git"
    GIT_3P_LIB_CLONE_URL="https://gitlab.private.aws.cradlepointecm.com/pcn/pcn-thirdparty-${TARGET}.git"
    GIT_PCN_BUILDTESTS_CLONE_URL="https://gitlab.private.aws.cradlepointecm.com/pcn/pcn-buildtest.git"
else
    echo "Cloning of build dependencies selected over ssh"
    GIT_TOOLCHAIN_CLONE_URL="git@gitlab.private.aws.cradlepointecm.com:pcn/pcn-tools-${TARGET}.git"
    GIT_3P_LIB_CLONE_URL="git@gitlab.private.aws.cradlepointecm.com:pcn/pcn-thirdparty-${TARGET}.git"
    GIT_PCN_BUILDTESTS_CLONE_URL="git@gitlab.private.aws.cradlepointecm.com:pcn/pcn-buildtest.git"
fi

if [ ! -d "${COMPILER_TOOLS}" ] ; then
	echo "Cloning pcn-tools-${TARGET} to ${COMPILER_TOOLS}"
	git clone --depth 1 --branch ${GIT_PCN_TOOLCHAIN_TAG} ${GIT_TOOLCHAIN_CLONE_URL} ${COMPILER_TOOLS} --progress
    rm -rf ${COMPILER_TOOLS}/.git
fi

if [ ! -d "${THIRDPARTY_ROOT}" ] ; then
	echo "Cloning pcn-thirdparty-${TARGET} to ${THIRDPARTY_ROOT}"
	git clone --depth 1 --branch ${GIT_PCN_THIRDPARTY_TAG} ${GIT_3P_LIB_CLONE_URL} ${THIRDPARTY_ROOT} --progress
    rm -rf ${THIRDPARTY_ROOT}/.git
fi

if [ ! -d "${BUILDTESTS_ROOT}" ] ; then
	echo "Cloning pcn-buildtests to ${BUILDTESTS_ROOT}"
	git clone --depth 1 --branch ${GIT_PCN_BUILDTESTS_TAG} ${GIT_PCN_BUILDTESTS_CLONE_URL} ${BUILDTESTS_ROOT} --progress
    rm -rf ${BUILDTESTS_ROOT}/.git
fi
ec
echo -e "\nCompiler Tools Release History:"
cat ${COMPILER_TOOLS}/releaseHistory
echo -e "\nThird-party Libs Release History:"
cat ${THIRDPARTY_ROOT}/releaseHistory

'''