From 03d236fdaef6e008d76b61a26b3b0f3f3f3ab08f Mon Sep 17 00:00:00 2001 From: BrianBoy Date: Sun, 28 Jun 2026 10:33:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20URL=20=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E7=BC=BA=E5=B0=91=20baseurl=E3=80=81=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=9C=B0=E5=9D=80=E6=A0=A1=E9=AA=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=A1=A5=20.git=E3=80=81pip=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=B7=BB=E5=8A=A0=20--ignore-installed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - shell/update/git.sh: URL 重定向时补上丢失的 $baseurl 变量 - shell/core/sync.sh: 仓库地址校验不强制要求 .git 后缀,没有则自动补上 - shell/core/sync.sh: 去除多余的 sed 's|\.git||g'(awk 已能正确提取仓库名和目录名) - shell/utils/dep.sh: pip3 install 添加 --ignore-installed 避免包冲突 --- shell/core/sync.sh | 9 ++++----- shell/update/git.sh | 4 ++-- shell/utils/dep.sh | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/shell/core/sync.sh b/shell/core/sync.sh index 55313e2e..6d9958fd 100755 --- a/shell/core/sync.sh +++ b/shell/core/sync.sh @@ -75,11 +75,10 @@ function gen_repoconf_array() { # echo -e "$WARN 未检测到第$(($arr_index + 1))个仓库配置的链接地址,跳过..." continue fi - # 判断仓库地址格式 + # 判断仓库地址格式,没有 .git 后缀则自动补上 echo "${tmp_url}" | grep -Eq "\.git$" # 链接必须以.git结尾 if [ $? -ne 0 ]; then - echo -e "$WARN 检测到第$(($conf_index + 1))个仓库配置的链接地址无效,跳过..." - continue + tmp_url="${tmp_url}.git" fi echo "${tmp_url}" | grep -Eq "https?:" if [ $? -ne 0 ]; then @@ -100,10 +99,10 @@ function gen_repoconf_array() { ## 代码仓库名称(如若未定义则采用链接地址中的仓库名称) Array_Repo_name[$conf_index]="$(get_config_wrapper "name")" if [[ -z "${Array_Repo_name[conf_index]}" ]]; then - Array_Repo_name[$conf_index]="$(echo ${Array_Repo_url[conf_index]} | sed "s|\.git||g" | awk -F "/|:" '{print$NF}')" + Array_Repo_name[$conf_index]="$(echo ${Array_Repo_url[conf_index]} | awk -F "/|:" '{print$NF}')" fi ## 代码仓库路径 - Array_Repo_dir[$conf_index]="$(echo "${Array_Repo_url[conf_index]}" | sed "s|\.git||g" | awk -F "/|:" '{print $((NF - 1)) "_" $NF}')" + Array_Repo_dir[$conf_index]="$(echo "${Array_Repo_url[conf_index]}" | awk -F "/|:" '{print $((NF - 1)) "_" $NF}')" Array_Repo_path[$conf_index]="$RepoDir/${Array_Repo_dir[conf_index]}" ## 代码仓库启用状态(默认启用) if [[ "$(get_config_wrapper_bool "enable" "true")" == "false" ]]; then diff --git a/shell/update/git.sh b/shell/update/git.sh index 6e2776fb..80f80848 100755 --- a/shell/update/git.sh +++ b/shell/update/git.sh @@ -45,7 +45,7 @@ function git_clone_with_http_auth() { if [[ "${url}" == http*://* ]] && [[ "${url}" != http*://*:*@* ]]; then local protocol=$(echo $url | awk -F/ '{print $1}') local baseurl=$(echo $url | awk -F/ '{print $3}') - url="${protocol}//${username}:${password}@${url#"$protocol"//"$baseurl"}" + url="${protocol}//${username}:${password}@${baseurl}${url#"$protocol"//"$baseurl"}" fi git_clone "${url}" "${dir}" "${branch}" "${text}" @@ -109,7 +109,7 @@ function reset_romote_url_with_http_auth() { if [[ "${url}" == http*://* ]] && [[ "${url}" != http*://*:*@* ]]; then local protocol=$(echo $url | awk -F/ '{print $1}') local baseurl=$(echo $url | awk -F/ '{print $3}') - url="${protocol}//${username}:${password}@${url#"$protocol"//"$baseurl"}" + url="${protocol}//${username}:${password}@${baseurl}${url#"$protocol"//"$baseurl"}" fi reset_romote_url "${work_dir}" "${url}" diff --git a/shell/utils/dep.sh b/shell/utils/dep.sh index 9baf2680..173e8c2d 100755 --- a/shell/utils/dep.sh +++ b/shell/utils/dep.sh @@ -379,7 +379,7 @@ function pip_dep_install() { echo "[dep.sh] ERROR: pip3 is not installed" >&2 return 1 } - pip3 install --no-cache-dir --break-system-packages "${pkg}" + pip3 install --no-cache-dir --break-system-packages --ignore-installed "${pkg}" } function pip_dep_uninstall() {