feat(Branches): 视图支持多选与分支/标签批量删除等批量操作; - #31
Merged
Conversation
- 视图改用 createTreeView({ canSelectMany: true }) 开启多选(registerTreeDataProvider 不支持);
- 批量化 branchDelete/tagDelete/copyBranchRef/toggleFavorite:作用于整个选区;删除仅一次 git branch --merged 分类已合并/未合并,单条确认弹窗分栏诚实呈现强制删除风险,逐个删除并汇总成功/失败、末尾单次刷新;
- 新增纯逻辑 engine/ref/selection.collectBranchRefs(选区归一化 + 点击在选区之外则以点击项为准)与 engine/ref/cleanup 的 partitionByMerged/formatBranchDeleteConfirm/truncateNames,单测全覆盖;
- package.json 对仅单目标命令(检出/合并/变基/重命名/比较)追加 !listMultiSelection 在多选时隐藏;同步更新 README/CHANGELOG/issue.md;
🤖 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>
ThreeFish-AI
added a commit
that referenced
this pull request
Jun 29, 2026
同步 #31(Branches 视图多选 + 批量删除/复制/收藏)与 #32(门控 Marketplace 自动发布以消除 deployments 报错);解决 CHANGELOG.md [Unreleased] 区段冲突——按 Keep a Changelog 顺序保留双条目(### Added → ### Changed)。 🤖 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 的 Branches 视图无法多选:一组功能/工作分支无法框选后批量操作(核心诉求是批量删除)。
根因:
hyperGit.branches经vscode.window.registerTreeDataProvider注册——该 API 不支持canSelectMany,故视图天然单选,且所有分支命令处理器只接收单个节点。多选能力仅createTreeView的TreeViewOptions支持。改动内容(What)
src/extension.ts将 Branches 改用createTreeView('hyperGit.branches', { canSelectMany: true })(句柄入subscriptions,对齐既有changesView写法),支持 Ctrl/Cmd/Shift 框选分支与标签。branchDelete/tagDelete/copyBranchRef/toggleFavorite扩展为接收 VS Code 多选树传入的(clickedNode, selectedNodes[]),作用于整个选区。git branch --merged <base>调用即对选区分类「已合并 / 未合并」,单条确认弹窗按桶诚实分栏呈现强制删除风险(已合并安全删 / 未合并强制删丢失提交),逐个删除并汇总成功/失败,末尾单次刷新。package.json追加&& !listMultiSelection,在多选时从右键菜单隐藏。[Unreleased]、docs/.agents/issue.md(docs+fix+release: M0-M5 文档沉淀 + M0-M4 审查补缺口 + v0.0.1-rc.1 发布准备 #8)。实现要点(How)
src/engine/ref/selection.ts的collectBranchRefs(谓词过滤 + 按shortName去重 + 「右键点击选区之外则以点击项为准」的手势优先归一化),与src/engine/ref/cleanup.ts的partitionByMerged/formatBranchDeleteConfirm/truncateNames;适配层src/adapter/branch-selection.ts仅做BranchNode → RawRef抽取后委托,维持「UI → Adapter → Engine」单向依赖。listMultiSelection:该上下文键对自定义贡献视图可靠性无法确证,仅作菜单整洁的视觉优化;单目标命令因仅读「点击项」即便该键失效仍安全。RawRef.head字段直接排除当前分支,无需解析分支名。验证(Verification)
pnpm run compile(check-types + lint + esbuild)✅pnpm run test:unit:197 passing(含新增ref-selection8 项与ref-cleanup扩展用例)✅pnpm run test:integration:3 passing——扩展以新createTreeView正常激活,批量命令注册校验通过 ✅