From 8b8336d9d054bfb2c67c36c222f6f4b20e93b4e0 Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 17 Nov 2022 22:01:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8D=87=E7=BA=A7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0gitee=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/share.sh | 13 +++++++------ shell/update.sh | 9 +++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/shell/share.sh b/shell/share.sh index c6b4252b..9c8714de 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -333,7 +333,6 @@ git_pull_scripts() { exit_status=$? git pull &>/dev/null unset_proxy - reset_branch "$branch" cd $dir_current } @@ -344,19 +343,21 @@ reset_romote_url() { local url=$2 local branch="$3" + cd $dir_work if [[ -d "$dir_work/.git" ]]; then - cd $dir_work [[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null git remote set-url origin $url &>/dev/null - - local part_cmd="" - reset_branch "$branch" - cd $dir_current + else + git init + git remote add origin $url &>/dev/null fi + reset_branch "$branch" + cd $dir_current } reset_branch() { local branch="$1" + local part_cmd="" if [[ $branch ]]; then part_cmd="origin/${branch}" git checkout -B "$branch" &>/dev/null diff --git a/shell/update.sh b/shell/update.sh index f2c5fed3..eba0ec04 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -247,6 +247,11 @@ usage() { update_qinglong() { patch_version &>/dev/null + local mirror="github" + local githubStatus=$(curl -s -m 3 -IL "https://github.com" | grep 200) + if [ "$githubStatus" == "" ]; then + mirror="gitee" + fi export isFirstStartServer=false local all_branch=$(git branch -a) @@ -255,7 +260,7 @@ update_qinglong() { primary_branch="${current_branch}" fi [[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json) - reset_romote_url ${dir_root} "https://github.com/whyour/qinglong.git" ${primary_branch} + reset_romote_url ${dir_root} "https://${mirror}.com/whyour/qinglong.git" ${primary_branch} git_pull_scripts $dir_root ${primary_branch} if [[ $exit_status -eq 0 ]]; then @@ -276,7 +281,7 @@ update_qinglong() { update_qinglong_static() { local no_restart="$1" local primary_branch="$2" - local url="https://github.com/whyour/qinglong-static.git" + local url="https://${mirror}.com/whyour/qinglong-static.git" if [[ -d ${ql_static_repo}/.git ]]; then reset_romote_url ${ql_static_repo} ${url} ${primary_branch} git_pull_scripts ${ql_static_repo} ${primary_branch}