From 023d0f1cc40e1e15726902480dba67e467542038 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Dec 2025 08:46:12 +0000 Subject: [PATCH] Fix pyproject.toml path handling and add error handling Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- back/config/util.ts | 4 ++-- shell/update.sh | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index 21da14f4..c9b939eb 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -600,8 +600,8 @@ export function getInstallCommand(type: DependenceTypes, name: string): string { // Check if it's a pyproject.toml file if (trimmedName.endsWith('pyproject.toml')) { // For pyproject.toml, install from the directory containing it - const dir = trimmedName.replace(/\/pyproject\.toml$/, '') || '.'; - return `${command} ${dir}`; + const dir = trimmedName.replace(/\/pyproject\.toml$/, ''); + return dir && dir !== 'pyproject.toml' ? `${command} ${dir}` : `${command} .`; } } diff --git a/shell/update.sh b/shell/update.sh index ab40cf72..fb340c11 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -133,10 +133,13 @@ auto_install_python_deps() { -X POST \ -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: Bearer ${__ql_token__}" \ - --data-raw "[{\"name\":\"${dep_name}\",\"type\":1,\"remark\":\"自动检测:${uniq_path} 订阅依赖\"}]" | jq -r '.code') + --data-raw "[{\"name\":\"${dep_name}\",\"type\":1,\"remark\":\"自动检测:${uniq_path} 订阅依赖\"}]" 2>/dev/null) - if [[ "$result" == "200" ]]; then + local code=$(echo "$result" | jq -r '.code' 2>/dev/null) + if [[ "$code" == "200" ]]; then echo -e "已添加 requirements.txt 依赖安装任务\n" + else + echo -e "添加 requirements.txt 依赖失败,请手动添加\n" fi fi @@ -153,10 +156,13 @@ auto_install_python_deps() { -X POST \ -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: Bearer ${__ql_token__}" \ - --data-raw "[{\"name\":\"${dep_name}\",\"type\":1,\"remark\":\"自动检测:${uniq_path} 订阅依赖\"}]" | jq -r '.code') + --data-raw "[{\"name\":\"${dep_name}\",\"type\":1,\"remark\":\"自动检测:${uniq_path} 订阅依赖\"}]" 2>/dev/null) - if [[ "$result" == "200" ]]; then + local code=$(echo "$result" | jq -r '.code' 2>/dev/null) + if [[ "$code" == "200" ]]; then echo -e "已添加 pyproject.toml 依赖安装任务\n" + else + echo -e "添加 pyproject.toml 依赖失败,请手动添加\n" fi fi }