Fix pyproject.toml path handling and add error handling

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-27 08:46:12 +00:00
parent f526d3f972
commit 023d0f1cc4
2 changed files with 12 additions and 6 deletions

View File

@ -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} .`;
}
}

View File

@ -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
}