linux-tutorial/codes/linux/libtest/git-update.sh

37 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2020-01-03 22:41:37 +08:00
#!/usr/bin/env bash
2020-02-12 22:46:17 +08:00
source ../lib/utils.sh
2020-01-03 22:41:37 +08:00
source ../lib/git.sh
doCloneOrPullGit() {
cloneOrPullGit $1 $2 $3 $4 $5
if [[ "$?" == "${SUCCEED}" ]]; then
printf "\n${C_GREEN}>>>> Update git project [$2/$3] succeed.${C_RESET}\n"
return ${SUCCEED}
else
printf "\n${C_RED}>>>> Update git project [$2/$3] failed.${C_RESET}\n"
return ${FAILED}
fi
}
##################################### MAIN #####################################
ROOT=$(dirname ${BASH_SOURCE[0]})
# 这里需要根据实际情况替换 Git 仓库、项目组、项目、代码分支
REPOSITORY="git@gitee.com"
printf "${C_CYAN}Current path is ${ROOT}.${C_RESET}\n"
doCloneOrPullGit ${REPOSITORY} turnon linux-tutorial master ${ROOT}
r1=$?
doCloneOrPullGit ${REPOSITORY} turnon nginx-tutorial master ${ROOT}
r2=$?
if [[ "${r1}" == "${SUCCEED}" && "${r2}" == "${SUCCEED}" ]]; then
2020-02-02 17:56:28 +08:00
printf "\n${C_B_GREEN}<<<< Init workspace Succeed.${C_RESET}\n\n"
2020-01-03 22:41:37 +08:00
exit ${SUCCEED}
else
2020-02-02 17:56:28 +08:00
printf "\n${C_B_RED}<<<< Init workspace Failed.${C_RESET}\n\n"
2020-01-03 22:41:37 +08:00
exit ${FAILED}
fi