From f117f6b39cacde0b2dcc4ec83eb68f403458e9c4 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 6 Mar 2022 11:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dshell=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/share.sh | 12 ++++++++---- shell/update.sh | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/shell/share.sh b/shell/share.sh index 3bc8de7a..80c3f36a 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -165,6 +165,8 @@ define_cmd() { } fix_config() { + make_dir $dir_static + make_dir $dir_data make_dir $dir_config make_dir $dir_log make_dir $dir_db @@ -316,14 +318,12 @@ git_pull_scripts() { local dir_current=$(pwd) local dir_work="$1" local branch="$2" - [[ $branch ]] && local part_cmd="origin/${branch}" cd $dir_work echo -e "开始更新仓库:$dir_work\n" set_proxy git fetch --all exit_status=$? - git reset --hard $part_cmd git pull unset_proxy @@ -336,12 +336,16 @@ reset_romote_url() { local url=$2 local branch="$3" - [[ $branch ]] && local part_cmd="origin/${branch}" - 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="" + if [[ $branch ]]; then + part_cmd="origin/${branch}" + git checkout -B "$branch" + fi git reset --hard $part_cmd &>/dev/null cd $dir_current fi diff --git a/shell/update.sh b/shell/update.sh index c9e18dbd..cc929b86 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -246,7 +246,11 @@ update_qinglong() { pnpm install -g pm2 &>/dev/null local no_restart="$1" + local all_branch=$(git branch -a) local primary_branch="master" + if [[ "${all_branch}" =~ "${current_branch}" ]]; then + 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} git_pull_scripts $dir_root ${primary_branch}