feat(Worktree): 新增 Worktree 视图与完整工作树操作功能 - #18
Merged
ThreeFish-AI merged 1 commit intoJun 29, 2026
Conversation
- 新增 hyperGit.worktrees 视图:经 git worktree list --porcelain -z 枚举工作树,区分主工作树 / 普通 / detached / locked / prunable,当前打开的工作树高亮; - 新增 9 个命令:刷新、新建(新建分支·检出已有·Detached 三模式)、打开(新窗口)、删除(普通/强制 + 二次确认)、复制路径、锁定、解锁、移动、清理(prunable 预览 + 确认); - 新增 engine 纯逻辑解析器 parseWorktreeList(NUL 段累积状态机,适配 -z 真实格式)+ vitest 单测; - 主工作树与当前打开工作树的删除/移动经菜单 when 与命令内双重守护; - API 不可用降级复用 EmptyChangesProvider,避免「视图未提供器」报错。 🤖 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.
背景
Hyper Git 活动栏容器(
hyper-git)下已有 Changes / Commit / Log / Branches / Stash / Shelf 六个视图,但缺少git worktree(工作树)的管理入口。用户在仓库内并行维护多个工作树(不同分支各开一个)时只能退回终端手动操作,体验断层。目标
新增
hyperGit.worktrees视图,提供完整的工作树管理能力,对齐 lazygit / GitKraken / VS Code 原生的工作树工作流。功能清单
视图:列出全部工作树(
git worktree list --porcelain -z),区分:home图标 + 「主」标注)git-branch/git-commit图标)9 个操作命令:
worktree prune实现要点
service.execGitCLI 通道(vscode.git 稳定 API 未暴露 worktree 创建/删除,对齐StashTreeProvider哲学)parseWorktreeList(NUL 段累积状态机)+ adapter TreeDataProvider,解析器可独立单测when+ 命令内双重拦截EmptyChangesProvider,避免「视图未提供器」报错验证
pnpm test:unit:178 个单测全绿(含 12 个parseWorktreeList用例)pnpm compile:tsc 类型检查 + eslint + esbuild 全过worktree list --porcelain -z喂给解析器,正确识别 main / detached / locked / prunable关键修正(循证工程)
实现中发现并修正了一个 porcelain 格式假设错误:
git worktree list --porcelain -z的-z是每字段 NUL 分隔、记录间空段(双 NUL),而非「记录级 NUL、块内\n」。该错误被单元测试的自洽掩盖,最终通过真实 git 端到端验证发现并修正解析器为 NUL 段累积状态机。🤖 Generated with Claude Code