添加工作树功能、优化提交历史加载逻辑并记录 Git 操作耗时 - #419
Conversation
| .canonicalize() | ||
| .unwrap_or_else(|_| reported_path.clone()); | ||
| Ok(GitWorktreeResponse { | ||
| path: path.to_string(), |
There was a problem hiding this comment.
[P1] Windows CI 当前会稳定复现失败:git worktree list --porcelain -z 返回的是 C:/... 路径,而新增测试通过 canonicalize() 得到的是 \\?\\C:\\...,导致 git_worktrees_lists_primary_linked_and_locked_metadata 在 Windows 上失败。\n\n另外,后面的 worktree mutation 在 4429 行使用 entry.path == destination 做字符串精确匹配;如果 UI 或调用方传入另一种等价的 Windows 路径表示,合法 worktree 也会被误报为未注册,进而无法锁定、解锁或删除。建议在 Rust Core 边界统一路径规范,并用规范化后的路径进行比较;同时把测试改成验证跨平台稳定的路径契约,而不是依赖 Windows 的 \\?\\ 表示。
|
@xiaoyumuxi\n\n这次 Review 发现一个需要处理的跨平台问题:新增的 worktree 测试在 Windows CI 上失败,原因是 Git 输出的路径格式与 |
| let reference = gitReferences.first { $0.fullName == worktree.branch } | ||
| let nextLimit = inspection.commits.count + 50 | ||
| let history = await service.history(at: worktree.url, reference: reference, limit: nextLimit) | ||
| guard gitWorktreeInspection?.worktreeID == worktree.id else { return } |
There was a problem hiding this comment.
[P1] 这里仅按 worktreeID 校验异步结果,无法区分同一路径在下一代 inspection 中产生的新状态。若用户在“加载更多”等待期间刷新或重新检查同一个 worktree,旧请求完成后会用它捕获的 inspection.changes 和旧 history 覆盖新一代结果。建议在请求开始时捕获 worktreeInspectionRequestGeneration,返回后同时校验 generation、worktreeID 和取消状态。
|
|
||
| let resolvedHistory = await history | ||
| guard generation == worktreeInspectionRequestGeneration, !Task.isCancelled else { | ||
| gitWorktreeInspectionLoadState = .idle |
There was a problem hiding this comment.
[P1] 旧的 inspection 请求返回时,即使 generation 已失效,这里仍会把共享的 gitWorktreeInspectionLoadState 改成 .idle。当用户快速切换 worktree 时,旧请求可能在新请求仍等待 Git history 时完成,导致新请求的 loading 状态被提前清掉,UI 会短暂显示错误的空闲/空结果状态。建议失效或取消的请求直接返回,不要修改共享状态。
概要
lithe.log。性能数据
在当前仓库使用真实 Git 命令进行 3 次预热、20 次采样:
git log --oneline -30git status --short当前仓库的 wall-clock 中位数下降约 22.6%。实际收益取决于仓库规模、磁盘和 Git 状态;核心行为是提交历史不再等待状态扫描完成。
日志示例
验证
swift test --package-path . --filter GitModuleTests:35 个测试通过verify-test-stability.sh:通过verify-service-boundaries.sh:通过git diff --check:通过稳定性报告:
.artifacts/test-stability/index.html