fix: 统一打包副本 Podfile 大小写

This commit is contained in:
shenlei 2026-07-20 14:34:18 +09:00
parent 2661435273
commit 2ad5f208ed
3 changed files with 23 additions and 2 deletions

View File

@ -105,7 +105,7 @@ COPY_ITEMS = [
"readoor.xcodeproj", "readoor.xcodeproj",
"readoorTests", "readoorTests",
"Vendor", "Vendor",
"podfile", "Podfile",
"Pods", "Pods",
"Podfile.lock", "Podfile.lock",
"readoor.xcworkspace", "readoor.xcworkspace",

View File

@ -486,6 +486,10 @@ async def copy_source_code(task_id: str, task, source_dir: Path) -> Path:
for item in COPY_ITEMS: for item in COPY_ITEMS:
src = source_dir / item src = source_dir / item
# 历史分支中该文件可能仍是小写 podfile构建副本统一使用 Pods.xcodeproj
# 引用的标准名称 Podfile避免大小写敏感文件系统报路径不一致。
if item == "Podfile" and not src.is_file():
src = source_dir / "podfile"
dst = build_dir / item dst = build_dir / item
if src.is_dir(): if src.is_dir():
await log_streamer.emit(task_id, f"拷贝目录: {item}") await log_streamer.emit(task_id, f"拷贝目录: {item}")

View File

@ -44,7 +44,7 @@ def tmp_dirs(tmp_path):
vendor_dir.mkdir(parents=True) vendor_dir.mkdir(parents=True)
(vendor_dir / "RDEpubReaderView.podspec").write_text("Pod::Spec.new do |s| end") (vendor_dir / "RDEpubReaderView.podspec").write_text("Pod::Spec.new do |s| end")
(source_dir / "readoorTests").mkdir() (source_dir / "readoorTests").mkdir()
(source_dir / "podfile").write_text("pod 'AFNetworking'") (source_dir / "Podfile").write_text("pod 'AFNetworking'")
build_dir = tmp_path / "build" build_dir = tmp_path / "build"
return source_dir, build_dir return source_dir, build_dir
@ -154,12 +154,29 @@ async def test_copy_source_code(tmp_dirs, log_streamer):
assert result.exists() assert result.exists()
assert (result / "readoor" / "AppDelegate.swift").exists() assert (result / "readoor" / "AppDelegate.swift").exists()
assert (result / "Pods").exists() assert (result / "Pods").exists()
assert (result / "Podfile").exists()
assert not (result / "podfile").exists()
assert (result / "Podfile.lock").exists() assert (result / "Podfile.lock").exists()
assert (result / "readoor.xcworkspace").exists() assert (result / "readoor.xcworkspace").exists()
assert (result / "Vendor" / "RDEpubReaderView" / "RDEpubReaderView.podspec").exists() assert (result / "Vendor" / "RDEpubReaderView" / "RDEpubReaderView.podspec").exists()
assert not (result / "AutoPacking").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): async def test_copy_source_code_excludes_git(tmp_dirs, log_streamer):
"""拷贝时排除 .git 目录""" """拷贝时排除 .git 目录"""
source_dir, build_dir_parent = tmp_dirs source_dir, build_dir_parent = tmp_dirs