From 2ad5f208ed521b3d59ae0d73baeffe1f088be328 Mon Sep 17 00:00:00 2001 From: shenlei Date: Mon, 20 Jul 2026 14:34:18 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=89=AF=E6=9C=AC=20Podfile=20=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/config.py | 2 +- backend/services/build_service.py | 4 ++++ tests/test_build_service.py | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/config.py b/backend/config.py index 3882a65..1fbaa52 100644 --- a/backend/config.py +++ b/backend/config.py @@ -105,7 +105,7 @@ COPY_ITEMS = [ "readoor.xcodeproj", "readoorTests", "Vendor", - "podfile", + "Podfile", "Pods", "Podfile.lock", "readoor.xcworkspace", diff --git a/backend/services/build_service.py b/backend/services/build_service.py index 49e63ba..2810cf8 100644 --- a/backend/services/build_service.py +++ b/backend/services/build_service.py @@ -486,6 +486,10 @@ async def copy_source_code(task_id: str, task, source_dir: Path) -> Path: for item in COPY_ITEMS: src = source_dir / item + # 历史分支中该文件可能仍是小写 podfile;构建副本统一使用 Pods.xcodeproj + # 引用的标准名称 Podfile,避免大小写敏感文件系统报路径不一致。 + if item == "Podfile" and not src.is_file(): + src = source_dir / "podfile" dst = build_dir / item if src.is_dir(): await log_streamer.emit(task_id, f"拷贝目录: {item}") diff --git a/tests/test_build_service.py b/tests/test_build_service.py index afa6d28..67212d1 100644 --- a/tests/test_build_service.py +++ b/tests/test_build_service.py @@ -44,7 +44,7 @@ def tmp_dirs(tmp_path): vendor_dir.mkdir(parents=True) (vendor_dir / "RDEpubReaderView.podspec").write_text("Pod::Spec.new do |s| end") (source_dir / "readoorTests").mkdir() - (source_dir / "podfile").write_text("pod 'AFNetworking'") + (source_dir / "Podfile").write_text("pod 'AFNetworking'") build_dir = tmp_path / "build" return source_dir, build_dir @@ -154,12 +154,29 @@ async def test_copy_source_code(tmp_dirs, log_streamer): assert result.exists() assert (result / "readoor" / "AppDelegate.swift").exists() assert (result / "Pods").exists() + assert (result / "Podfile").exists() + assert not (result / "podfile").exists() assert (result / "Podfile.lock").exists() assert (result / "readoor.xcworkspace").exists() assert (result / "Vendor" / "RDEpubReaderView" / "RDEpubReaderView.podspec").exists() assert not (result / "AutoPacking").exists() +async def test_copy_source_code_normalizes_lowercase_podfile(tmp_dirs, log_streamer): + """旧分支的 podfile 也必须复制为 Pods 工程引用的 Podfile。""" + source_dir, build_dir_parent = tmp_dirs + (source_dir / "Podfile").unlink() + (source_dir / "podfile").write_text("pod 'AFNetworking'") + task = MagicMock(branch="main") + + with patch("backend.services.build_service.BUILD_BASE_DIR", build_dir_parent): + result = await copy_source_code("t1", task, source_dir) + + copied_names = {path.name for path in result.iterdir()} + assert "Podfile" in copied_names + assert "podfile" not in copied_names + + async def test_copy_source_code_excludes_git(tmp_dirs, log_streamer): """拷贝时排除 .git 目录""" source_dir, build_dir_parent = tmp_dirs