Skip to content

fix(windows): send diff pathspecs the shared core accepts - #102

Closed
yangboxuan726 wants to merge 1 commit into
1lck:preview/0.3.0from
yangboxuan726:fix/windows-git-diff-pathspec
Closed

fix(windows): send diff pathspecs the shared core accepts#102
yangboxuan726 wants to merge 1 commit into
1lck:preview/0.3.0from
yangboxuan726:fix/windows-git-diff-pathspec

Conversation

@yangboxuan726

Copy link
Copy Markdown
Contributor

问题

Windows 的单文件 diff 与变更统计两条通路把 filePath 映射进了 Core 不认识的 paths 字段,而 git.diff 契约要求 pathspecs 且拒绝空数组(mod.rs 校验 pathspecs 非空):

  1. 点已修改的已跟踪文件 → Core 拒绝 → getFileDiff 静默失败返回 null → 上层回退为打开原文件,diff 视图永远不出现,且无任何报错;
  2. git_status_diff_stats 同样被拒 → Changes 列表完全没有 +/- 行数统计;
  3. stats 适配层把 staged 写死为 false,即使前两项修好,已暂存文件也永远没有统计数字。

修复

  • platform.rsgit_diff_file / git_status_diff_statsfilePath 改映射到 pathspecs;不带 filePath 时兜底 ["."](整树,与 git_ref_diff 现有写法一致)
  • core-result-adapter.ts:diff stats 的 staged 改从请求参数读取,不再硬编码
  • git-diff-api.ts:stats 并取未暂存 + 已暂存两组(Core 的 staged 参数现成支持),两组文件都能显示统计
  • 未跟踪文件点击直接打开原文件的既有行为保持不变

验证

  • cargo test(src-tauri):11/11 通过(新增 2 个翻译测试:带 filePath 的 pathspec 映射、stats 整树兜底)
  • bun test:12/12 通过(新增 3 个 adapter 测试:stats 双文件计数、staged 透传、单文件 diff 适配)
  • tsc --noEmit:通过
  • 真机验收通过:点已修改的已跟踪文件打开 diff 视图(修复前打开原文件);staged diff 正常;Changes 列表出现 +/- 统计(含已暂存文件);commit / stash 无回归

关联

- translate git_diff_file and git_status_diff_stats filePath into the
  git.diff pathspecs contract instead of the unrelated paths field, and
  fall back to ["."] so whole-tree stat requests are not rejected
- derive diff stat staged flags from the request instead of hardcoding
  false, and fetch staged and unstaged stats so both groups show counts
@yangboxuan726
yangboxuan726 requested a review from 1lck as a code owner August 16, 2026 01:19
@yangboxuan726

Copy link
Copy Markdown
Contributor Author

Superseded by #103, which carries this exact fix (verified identical commit content) plus the follow-up diff/history work. Closing to keep the review queue clean — please review #103 instead.

@yangboxuan726
yangboxuan726 deleted the fix/windows-git-diff-pathspec branch August 16, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant