fix(windows): align local branch checkout and deletion refs - #101
Merged
1lck merged 3 commits intoAug 16, 2026
Merged
Conversation
- qualify git_checkout, git_checkout_preflight, and git_delete_branch references with refs/heads/ and pass referenceKind: local, matching the shared core contract that rejects short branch names - translate git_checkout_preflight to git.checkoutPreflight and adapt its blocking paths plus git_checkout results for the branch manager UI - run checkout preflight from checkoutBranch so blocked switches surface hasChanges and reuse the existing stash-and-retry flow, and propagate real git error output on failure
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.
问题
Windows 分支切换和删除调用链存在三处契约错位,导致两个操作都会被共享 Core 拒绝:
git_checkout/git_delete_branch翻译层只传短分支名,而 Core 的local_branch_name()要求完整引用refs/heads/<branch>;git_checkout缺少referenceKind,Core 的switch_reference()对缺省值直接返回invalid_request;core-result-adapter没有git_checkout适配分支,前端拿到的原始{output, exitCode}缺少success/hasChanges,成功切换也不会触发状态刷新。修复
platform.rs:新增local_branch_reference()统一补全refs/heads/前缀(仅对已是refs/heads/开头的值透传);git_checkout传referenceKind: "local";新增git_checkout_preflight→git.checkoutPreflight翻译;git_delete_branch走同样的限定引用core-result-adapter.ts:补git_checkout(exitCode/output → success/message)与git_checkout_preflight(blockingPaths)适配git-branches-api.ts:切换前先跑 preflight,阻塞时返回hasChanges: true复用现有 Stash Changes 重试流程;失败信息透传 git 真实输出UI 组件、Rust Core、macOS 实现均未改动。
验证
cargo test(src-tauri):13/13 通过(新增 checkout / preflight / deleteBranch 翻译测试及 helper 边界测试)bun test:14/14 通过(新增 5 个 adapter 适配测试)tsc --noEmit:通过后续
checkoutBranchcatch 路径的 API 层错误传播测试计划随下一个 PR 补充(需要 invoke 模块 mock)scripts/verify-windows-boundaries.sh在 Windows 存在基线既有的路径分隔符误报(白名单正则用/,rg 输出\),与本 PR 无关,可单独修复