Repository navigation
feat(core): #1662 车道 B Git 写入下沉(GIT-21/22) - #1755
Merged
Merged
Conversation
- Core 新增 git.planDiffBlocks / git.applyDiffBlock / git.stageGutterChange:由 Core 计划提交评审块、持有 include/exclude/rollback patch,并在仓库写锁内校验快照令牌后写入 - 完整文件 diff 的 hunk 由 Core 按 Git 默认上下文拆分,并返回逐 hunk 字节保真 patch 与 lineStart/lineEnd - git.apply discard 在写锁内检查 filter 与 working-tree-encoding,删除 unidiffZero 参数 - Windows 删除 TS 侧块规划、gutter patch 拼接、check-attr 与 U0 patch 切片,以及 Tauri host 的 hunk_patch 重建 - 新增共享 fixture 与 Core 集成测试,更新功能矩阵与 rust-core-api 契约 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- git.applyDiffBlock 新增 includeFile / excludeFile,blockId 可选;写锁内重新规划,令牌不一致返回 GIT_DIFF_BLOCK_STALE,校验统一在 Core,不恢复 TS 快照比对 - Windows 整文件暂存/取消暂存改走 Core 令牌写入 - 新增 git.diff.rollbackUnsafe 中英文案,块评审与 hunk 回滚遇 GIT_HUNK_ROLLBACK_UNSAFE 时显示该原因 - 共享 fixture 增加 wholeFileWriteCases,补 Rust 与 Windows 测试 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
本地验证(代替 GitHub macOS / Windows CI)本 PR 与 #1760、#1755、#1753、#1759、#1756、#1758、#1757 一起,在本地集成分支 macOS(本机,macOS 26.6 arm64)
Windows(lithe-dev,Windows Server)
合并前每个 PR 已 rebase 到最新 preview,并重新执行编译、i18n、 |
1lck
force-pushed
the
feat/issue-1662-b-git-writes
branch
from
November 5, 2026 09:21
fa12be3 to
2735228
Compare
1lck
marked this pull request as ready for review
November 5, 2026 09:26
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
引用 #1662(车道 B:Git 写入)。完成 GIT-21、GIT-22;GIT-20 已在 #1688/#1690 完成,本 PR 在其基础上做。
改动
git.planDiffBlocks、git.applyDiffBlock、git.stageGutterChange(rust/lithe-core/src/git/diff_blocks.rs)。Core 读取 HEAD→worktree 与 HEAD→index 两份完整文件 diff,计算块 ID、checked / indeterminate、暂存造成的坐标偏移、include / exclude / rollback 三类 patch 并自己持有;返回内容不含 patch 文本,只含块描述和快照令牌token。git.applyDiffBlock在仓库写锁内重新规划,令牌不一致返回GIT_DIFF_BLOCK_STALE;git.stageGutterChange复核索引与已保存文件仍显示编辑器比较过的行,否则返回GIT_GUTTER_CHANGE_STALE。均保留快照校验,没有放宽。git.applyDiffBlock的rollback与git.apply的discard模式)在写锁内用git check-attr复核filter/working-tree-encoding,不安全时返回GIT_HUNK_ROLLBACK_UNSAFE。git.apply删除unidiffZero参数(--unidiff-zero不再使用),回滚始终带上下文并由git apply校验。git.diff(includeFileSections+ 完整上下文)由 Core 拆成 Git 默认 3 行上下文的 hunk,每个 hunk 带字节保真patch和lineStart/lineEnd;无法拆分时不提供可写 hunk(fail closed)。commit-diff-blocks.ts的块规划、lossy-rollback-attrs.ts(自拼check-attr)、lossy-rollback-patch.ts(U0 patch 切片)、gitGutterChangeHunk(gutter patch 拼接)、git-diff-api.ts的writePatch/ 原始 patch 重读 /isWorktreeWritePatchCurrent,以及 Tauri hostplatform.rs的hunk_patch重建。hunk 写入只接受 Core 返回的rawPatch。git-diff-block-api.ts;commit-diff-review改为读 Core 计划、按blockId + action + token写入;gutter 暂存改调git.stageGutterChange;core-result-adapter适配git.planDiffBlocks并透传 hunk 行范围;monaco-diff-rows使用 Core 的 hunk 范围与 patch。shared/contracts/rust-core-api.md追加三个命令与错误码;shared/fixtures/git/diff-blocks-v1.json新增共享 fixture;功能矩阵editor-git-gutter-stage/git-diff-review/git-status-commit的证据路径更新。整文件写入与回滚不安全提示
git.applyDiffBlock新增includeFile/excludeFile(blockId可选):整文件暂存/取消暂存同样带token,在写锁内重新规划,不一致返回GIT_DIFF_BLOCK_STALE。校验只在 Core,Windows 不再保留 TS 快照比对。fixture 新增wholeFileWriteCases,Rust 测试whole_file_inclusion_is_bound_to_the_planned_token。git.diff.rollbackUnsafe(中英),块评审和 hunk 回滚遇到GIT_HUNK_ROLLBACK_UNSAFE时显示这一具体原因,不再是通用写入失败。两端行为变化
filter/working-tree-encoding文件仍禁止块回滚,回滚被拒绝时显示专门的不安全提示。块写入遇到文件已变化时显示原有的过期提示。git.apply discard在 Core 内复核属性;被拒绝时GIT_HUNK_ROLLBACK_UNSAFE作为错误信息返回。验证
通过:
cargo test --lib git(395 passed,含git_diff_blocks10 项:fixture、真实 Git 的 include / exclude / rollback、CRLF 字节往返、eol / filter 属性、写前文件变化被拒)verify-rust-core-comments.sh、verify-shared-contracts.sh、verify-service-boundaries.sh、verify-core.sh、verify-windows-boundaries.sh、verify-platform-feature-matrix.sh--check与 app-language 检查(新增git.diff.rollbackUnsafe)tsc --noEmit(仅frontend/editor既有的 textmate 依赖缺失错误);相关 bun 测试逐文件通过(monaco-diff-hunk-actions、monaco-diff-rows、commit-diff-review、use-commit-diff-review、git-gutter-changes、core-result-adapter.*等)未通过 / 未执行:
verify-rust-core.sh:失败于cargo fmt --check,涉及build_systems.rs、declarative_plugins.rs、marketplace_plugins.rs、plugin_editor_resources.rs的既有格式问题,非本 PR 文件;本 PR 的diff_blocks.rs/git_diff_blocks.rs已格式化。cargo check --bin lithe-windows在 macOS 主机上只出现std::os::windows/as_raw_handle两个既有平台错误,无新增;platform.rs的 Rust 测试因此无法在本机编译,需看 Windows CI。test-macos.sh未执行(本机非 macOS 构建环境,macOS 无代码改动);未做 Windows / macOS 实机验证。🤖 Generated with Claude Code