Repository navigation
fix(Branches): 修复 Delete Remote Branch 对陈旧远程分支误报失败且吞掉真实原因 - #147
Merged
ThreeFish-AI merged 2 commits intoOct 17, 2026
Merged
Conversation
- 服务端已无此 ref(PR 合并后远端自动删除、本地 tracking ref 未 prune)时,
push --delete 被拒的「remote ref does not exist」不再误报失败——按目标态已
达成收尾,并把本地陈旧 tracking ref 纳入 branch -D -r 清理;
- 真失败(保护分支拒绝/认证/网络等)经 stderr 优先提取原因,通知中逐分支附上
真实报错并联动 Show Output,替换原先 catch{} 吞错后的笼统「N failed」;
- engine 纯逻辑新增 isRemoteRefMissingError / formatRemoteDeleteResult
(零 vscode 依赖),新增 18 个单测覆盖分类与三桶汇总。
🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- 抽取 engine/git-state/git-error.ts 的 gitErrorText 作为「stderr 优先提取」 单一事实源,remote-commands 与 history-commands 两处内联 errMsg 改为引用, 消除本 PR 引入的同逻辑第三份拷贝与语义漂移面; - formatRemoteDeleteResult 零计数段省略(仅陈旧项时不再以「Deleted 0 remote branches」开头)并复用 truncateNames 截断(SSOT);isRemoteRefMissingError 空白 stderr 回退 message 与 errMsg 守卫语义对齐; - issue.md #19 同步 gitErrorText 术语;新增/强化 20 个单测(494 全绿)。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
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.
问题
rsi 等仓库的
origin/rsi/fixture-terminology类远程分支,在 Branches 视图右键「Delete Remote Branch」删除直接报错:无任何失败原因,且此类分支「经常」删不掉。
根因(已在 rsi 仓库实证)
复合缺陷,两个 Bug 叠加:
fetch --prune前一直陈旧,视图仍列出;对它执行git push origin --delete被服务端拒绝(git 2.54 实测 stderr:error: unable to delete 'x': remote ref does not exist)。remote-commands.ts删除循环的catch {}把execGit已透传挂载的 stderr 整个丢弃,最终只回显笼统的「N failed」,不可诊断。修复
src/engine/ref/remote-ref.ts,零 vscode 依赖):isRemoteRefMissingError:识别「服务端已无此 ref」的 push 失败(stderr 优先,匹配remote ref does not exist/delete of non-existent ref变体);formatRemoteDeleteResult:把逐分支删除结果三桶(成功 / 服务端已不存在 / 真失败)汇总为通知文案与级别。src/adapter/remote-commands.ts):branch -D -r清理(通知如实标注 already gone on remote);errMsg提取原因(与history-commands.ts同款先例),通知中逐分支附上真实原因,失败走showGitError联动 Show Output 查看完整输出;验证
pnpm run check-types✅、pnpm run lint✅、pnpm test:unit✅(493/493,含新增 18 个用例:分类器实测文案命中/变体/负例,三桶汇总全组合/截断/单复数/级别);origin/rsi/fixture-terminology→ Delete Remote Branch → 应显示「already gone on remote (pruned local tracking ref)」且视图中幽灵 ref 消失;对真实存在/受保护的远端分支分别验证成功与带原因失败两条路径。🤖 Generated with Claude Code