This commit is contained in:
anonymous 2021-04-08 20:06:49 +08:00
parent 37a16510c6
commit c90a0ce579

View File

@ -18,6 +18,20 @@ fix_config
import_config_no_check "update"
get_token
## 重置仓库remote urldocker专用$1要重置的目录$2要重置为的网址
reset_romote_url () {
local dir_current=$(pwd)
local dir_work=$1
local url=$2
if [ -d "$dir_work/.git" ]; then
cd $dir_work
git remote set-url origin $url >/dev/null
git reset --hard >/dev/null
cd $dir_current
fi
}
## 克隆脚本,$1仓库地址$2仓库保存路径$3分支可省略
git_clone_scripts () {
local url=$1
@ -250,8 +264,8 @@ update_own_repo () {
[[ ${#array_own_repo_url[*]} -gt 0 ]] && echo -e "--------------------------------------------------------------\n"
for ((i=0; i<${#array_own_repo_url[*]}; i++)); do
if [ -d ${array_own_repo_path[i]}/.git ]; then
reset_romote_url ${array_own_repo_path[i]} ${array_own_repo_url[i]} &>/dev/null
git_pull_scripts ${array_own_repo_path[i]} ${array_own_repo_branch[i]}
reset_romote_url ${array_own_repo_path[i]} ${array_own_repo_url[i]}
git_pull_scripts ${array_own_repo_path[i]}
else
git_clone_scripts ${array_own_repo_url[i]} ${array_own_repo_path[i]} ${array_own_repo_branch[i]}
fi