Skip to content

feat(Parity): 复刻 IDEA Git 工具窗口全量功能(Branches/Log/Graph/Merge/Rebase); - #15

Merged
ThreeFish-AI merged 9 commits into
feature/1.x.xfrom
ThreeFish-AI/idea-git-feature-parity-review
Jun 29, 2026
Merged

feat(Parity): 复刻 IDEA Git 工具窗口全量功能(Branches/Log/Graph/Merge/Rebase);#15
ThreeFish-AI merged 9 commits into
feature/1.x.xfrom
ThreeFish-AI/idea-git-feature-parity-review

Conversation

@ThreeFish-AI

@ThreeFish-AI ThreeFish-AI commented Jun 29, 2026

Copy link
Copy Markdown
Owner

背景(Why)

用户安装当前 Hyper Git 后对照 IntelliJ IDEA Git 工具窗口,反馈「功能明显少了很多」:Branches 一个分支都列不出、缺 IDEA 左侧工具栏 Action 组(fetch/pull/compare/delete/new branch 等)、Commit Log 操作不一致。

3 路独立代码审计(命令处理器 / Webview UI / 引擎与测试)核实:绝大多数功能其实已实现(56 命令 + git CLI 通道已补齐 cherry-pick/revert/reset/hunk 暂存等),但被三类问题掩盖——视图渲染 bug(Branches 空白)、工具栏 Action 未浮现、若干命令 bug;同时 Graph/Rebase/冲突解决等是真实缺口。本 PR 据此「先解除可见痛感,再全量对齐」。

变更(What)

新增 13 个 engine 纯逻辑模块 + 21 个命令(命令 56→77、单测 64→166),42 文件 +3501/-155,分 9 个提交(Batch5-13):

  • Branches 渲染修复 + 工具栏 + 冲突兜底engine/ref/for-each-ref + async getChildren + CLI 兜底 + 首帧刷新(根治「空白」);补齐各视图 view/title 工具栏 Action;engine/git-state/conflict-detector + adapter/conflict-ui(merge/rebase/cherry-pick 等失败检测冲突弹「解决/中止」)。
  • Branches 对齐 IDEA:Favorites/Local/Remote/Tags 四段分组 + ahead-behind/upstream 展示 + 收藏持久化 + checkout-as-new/compare/tags 全周期。
  • Rebase webview 1:1 复刻:补 reword/edit + 拖拽重排序;reword 经 process.execPath 跑 Node editor helper 非交互写入新 message。
  • Log 增强:commit 展开看变更文件 + 单文件 diff(commit^ vs commit)+ 高级过滤(grep/合并模式/日期/正则)+ per-commit 操作(resetToHere/createBranch/createTag/包含分支)。
  • 真实 SVG 拓扑图:解析 git log --graph 字符粒度渲染(* 圆点可点击 / |/\\ 连线 / 多色 lane)+ 实时刷新。
  • Push/Update/Merge 对话框:force/force-with-lease/push tags、merge ff/no-ff/squash、pull --rebase/--no-rebase;fetch --prune;Co-authored-by trailer。
  • 自绘 3-way Merge Editor:自实现 engine/merge/diff3(基于 LCS,双方同改动自动消解)+ 三栏(OURS/RESULT/THEIRS)冲突解决 + 写回 git add
  • Phase 4/5 收尾:Stash 高级(keep-index/clear/branch)、Patch create/apply、Reflog、编辑器内 Blame 行内注解。

关键实现细节(Details)

  • 架构分层:所有 CLI 输出解析逻辑提取到 engine/(零 vscode 依赖、Vitest 可测),adapter 仅做 vscode 接线;git 底座稳定 API 优先、缺口走 GitRepositoryService.execGit(复用 api.git.path 同一二进制)。
  • 真实性验证:diff3 / graph-parser / blame-parser / reword helper / 真实 git 冲突阶段(:1/:2/:3)均做真实 git 数据功能性验证(不止单测)。
  • 质量基线:类型检查 / ESLint / esbuild 生产构建全程干净;单测 166/166、集成 3/3(test-electron 真实 VS Code,每批次回归)。
  • 文档:CHANGELOG / 实施状态 / README 同步更新。

待补(非阻塞)

Commit webview 的 Co-authored-by/author 覆盖按钮接线、Partial 多文件 UX、目录 diff、Submodules、M5 AI Agent(5 个接缝已预埋 Null 实现)。

🤖 Generated with Claude Code

…突兜底引导;

- Phase 0a(解除最大痛感):新增 engine/ref/for-each-ref 纯解析器(NUL 分隔字段,含 upstream/HEAD 标记);branches-tree 改 async getChildren + repo.state.refs 为空时 git for-each-ref CLI 兜底(复用 stash-tree 范式)+ 构造函数自订阅 service.onDidChange;extension 首帧 setTimeout 刷新(修复 repo 在 activate 前已就绪时初始 _onDidChange.fire 早于订阅挂载而被丢失、导致视图永久空白的根因)
- Phase 0b(工具栏 Action 组补齐):Changes 视图加 fetch/pull/push/commit/commitAndPush;Branches 加 fetch;Log 加 cherry-pick/revert/reset;cherry-pick/revert 成功后刷新 branchesTree+logTree(registerGitCliCommands 增 logTree 参数);resetHead 重写为选目标 commit + 选模式(修复固定 HEAD~0 导致 mixed/keep 等同空操作);branchDelete 加 --merged 检查决定 -d/-D;merge/rebase 加破坏性操作 modal 确认
- Phase 0c(冲突兜底引导):新增 engine/git-state/conflict-detector 纯逻辑(解析 porcelain 未合并条目 + .git 标记判定 ongoing merge|rebase|cherry-pick|revert)+ adapter conflict-ui;merge/rebase/pull/cherry-pick/revert/stash-pop/unshelve-with-merge 失败时检测冲突弹「解决/中止」,中止执行 git <op> --abort
- 测试:新增 for-each-ref(9)+ conflict-detector(11)单测;单测 84/84、集成 3/3、lint/类型检查/生产构建全绿

🤖 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>
…ehind/upstream + 6 新命令);

- engine/ref/for-each-ref 扩展 %(upstream:track)(6 字段),RawRef 增 ahead?/behind? 解析
- 新增纯逻辑 engine 模块:ref/favorites(toggleFavorite/isFavorite)、ref/cleanup(filterMergeable/isProtectedBranch,提取自 cleanupBranches 并复用)、rebase/todo(parseTodo/serializeTodo/reorderTodo,供子批次 2b rebase webview)
- adapter/branch-favorites:分支收藏 workspaceState 持久化(仿 ChangelistRegistry + onDidChange)
- BranchesTreeProvider 升级:Favorites/Local/Remote/Tags 四段分组(收藏置顶、HEAD 优先排序);description 显示 ↑ahead ↓behind ★;tag 节点 contextValue;refs in-flight 去重缓存(避免多段并发重复 spawn CLI)
- 6 新命令:toggleFavorite(inline 星标 + 收藏段)、checkoutAsNew(从选中分支新建并检出)、compareWithCurrent(HEAD...selected diff --stat)、tagCreate/tagDelete/tagCheckout(标签全周期)
- 测试:新增 ref-favorites/ref-cleanup/rebase-todo 单测,for-each-ref 增 ahead-behind 用例;单测 107/107、集成 3/3、lint/类型/构建全绿

🤖 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>
- action 下拉补 reword/edit(对齐 IDEA 全 6 动作 pick/reword/edit/squash/fixup/drop)
- reword 行内可编辑 message:选 reword 时 subject input 启用并聚焦(其余动作只读)
- HTML5 拖拽重排序:dragstart/dragover/drop 移动 DOM 行 + 视觉反馈(dragging/drop-target),submit 按 DOM 顺序读取
- 正确实现非交互 reword:写 Node editor helper(用 process.execPath 运行,规避 PATH 缺 node)+ state 文件({counter,subjects}),GIT_EDITOR 按调用顺序写入新 message(已功能性验证:多 reword 按序写入 + counter 递增 + 超范围保留)
- todo 构造改用 engine/rebase/todo.serializeTodo + isValidAction 校验(复用纯逻辑)
- edit/冲突暂停检测:rebase 后探测 .git/rebase-merge 存在 → 提示 continue/skip/abort;catch 接 handleGitConflict
- retainContextWhenHidden 保留 webview 状态
- 验证:类型/lint/构建干净,单测 107/107(rebase-todo 8),集成 3/3,reword helper 功能测试通过

🤖 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/log/log-filter:纯逻辑客户端过滤(mergeMode/dateFrom/dateTo/messageRegex + safeRegex),engine 零 vscode 依赖(FilterableCommit 抽象)
- engine/log/commit-files:纯逻辑 parseNameStatus 解析 git diff-tree --name-status(含 R/C rename oldPath)
- LogTreeProvider 升级:commit 节点改 Collapsed,展开经 diff-tree 显示变更文件;merge commit 用 git-merge 图标;高级过滤(grep/合并模式/日期/正则);file 节点状态色(added/deleted/renamed/modified)+ 点击打开 diff
- 5 per-commit 命令:openCommitFileDiff(hash^ vs hash,root 单版本)、resetToHere(选模式 reset 到此 commit)、createBranchFromCommit、createTagFromCommit、showContainingBranches(git branch --contains)
- 4 过滤命令:logFilterGrep(--grep)/logFilterMergeMode(全部|仅合并|仅非合并)/logFilterDate(7|30|90 天)/logFilterRegex(客户端正则)
- 验证:类型/lint/构建干净,单测 128/128(新增 log-filter 12 + log-commit-files 9),集成 3/3

🤖 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/log/graph-parser:纯逻辑 parseGraphLog(NUL 分隔 graph/hash/decorate/subject,续行无 NUL)+ normalizeGraphWidth(列对齐)+ classifyGraphChar
- graph-webview 完全重写为 SVG:按字符粒度还原 git 已分配的 lane 布局(*→可点击圆点、|→竖线、/→斜线、_→横线),按列 floor(col/2) 多色着色(类 IDEA 多色 lane);commit 行右侧绘制 hash/refs/subject 文本(refs 着色)
- 节点可点击:postMessage hash → host QuickPick per-commit 操作(cherry-pick/revert/reset/new branch/new tag/包含分支/复制 hash)
- 实时刷新:订阅 service.onDidChange(400ms 防抖)重新获取并重绘;panel dispose 释放订阅
- 已用本仓库真实 git log --graph 验证格式兼容(NUL 分隔 + graph ASCII 前缀)
- 验证:类型/lint/构建干净,单测 136/136(新增 graph-parser 8),集成 3/3

🤖 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>
…ed-by trailer;

- engine/commit/trailer:纯逻辑 appendCoAuthoredBy(正确区分 trailer 块 vs CC subject,重复不追加)+ authorArg;修正「feat: x 单行被误判 trailer」
- adapter/remote-commands:Push 对话框(待推送预览 + remote + force/force-with-lease + push tags)、Update Project(merge/rebase 策略 pull)、Merge 对话框(ff-only/no-ff/squash + 自定义 message);均接 handleGitConflict
- fetch 增强:QuickPick 普通/Prune(清理已删除远程分支),repo.fetch({prune})
- package.json:3 新命令 + Changes/Branches 视图工具栏入口
- 验证:类型/lint/构建干净,单测 143/143(新增 commit-trailer 7),集成 3/3

🤖 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/merge/diff3:纯逻辑自实现三方合并(基于 LCS 求 base↔ours/base↔theirs 匹配锚点,diff3 规则判定 stable/conflict;双方同改动/单方改动自动消解,仅双方不同改动才冲突)+ resolveHunk(ours/theirs/both/base/manual) + conflictCount
- adapter/webview/merge-editor:WebviewPanel 三栏(OURS | RESULT 可编辑 | THEIRS),stable 段只读、conflict 段 Accept 按钮(Ours/Base/Theirs)填 RESULT,默认 RESULT 含冲突标记;保存拼装全量结果写回 + git add 标记已解决,残留标记二次确认
- registerMergeCommands:resolveConflicts(列冲突文件→打开 editor)、acceptOurs/acceptTheirs(git checkout --ours/--theirs + add 快捷)
- handleGitConflict「解决冲突」直接调起 resolveConflicts(Phase 0c 引导接入 Phase 3 editor)
- 数据:git show :1/:2/:3 取三阶段 → diff3
- 已用真实 git 冲突(UU 文件)验证:阶段可读 + diff3 正确判定冲突段数
- 验证:类型/lint/构建干净,单测 159/159(新增 diff3 16),集成 3/3

🤖 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>
…行内注解);

- Stash 高级:stashKeepIndex(--keep-index 保留已暂存)、stashClear(清空)、stashBranch(git stash branch 从 stash 创建分支)
- misc-commands:createPatch(导出未暂存/已暂存/全部改动为 .patch)、applyPatch(应用 patch,支持 --index/--3way/--check 模式)、showReflog(git reflog 渲染)
- engine/blame/blame-parser:纯逻辑解析 git blame --line-porcelain(同 commit 块复用元数据缓存)+ formatAnnotation
- adapter/editor/blame-annotation:BlameAnnotationController 用 TextEditorDecorationType before 行内渲染每行作者·日期(IDEA Annotate 等价),toggle 开关、文档变更自动清理、hover 显示 sha/summary
- package.json:7 新命令 + Stash/Log/Changes view/title + stash 右键 + editor/context(blame)
- 真实 git blame --line-porcelain 验证解析器格式兼容
- 验证:类型/lint/构建干净,单测 166/166(新增 blame-parser 7),集成 3/3

🤖 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>
- CHANGELOG [Unreleased]:详记 Batch5-12 全部交付(13 engine 模块 + 21 命令,单测 64→166、命令 56→77)+ 待补项
- implementation-status:更新「最后更新」+ Batch5-12 重大更新说明(API 限制已由 execGit CLI 解决)+ 里程碑表追加 3 行 Recovery 汇总
- README 已知限制:改写为「多数已由 CLI 解决」+ 列出真实剩余待补项
- 验证:类型/lint/构建/166 单测/集成 3/3 全绿(文档无构建影响)

🤖 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 ThreeFish-AI changed the title feat(Parity): IDEA Git 工具窗口全量对齐复刻; feat(Parity): 复刻 IDEA Git 工具窗口全量功能(Branches/Log/Graph/Merge/Rebase); Jun 29, 2026
@ThreeFish-AI
ThreeFish-AI merged commit 018cb70 into feature/1.x.x Jun 29, 2026
4 checks passed
ThreeFish-AI added a commit that referenced this pull request Jul 6, 2026
缺失端(新增文件无旧端、删除文件无新端)改用 git 空树 ref 构造 URI,跨 VS Code 版本稳定解析为空内容,修复新版 readFile 对不存在具名 ref 抛 FileNotFound 致差异打不开。按状态正交分解:新增空树置旧端、删除空树置新端、重命名两端异路径;补齐 Graph 视图逐文件 status/oldPath 传参与干净路径,修复重命名点击崩溃;新增分类器与端点解析的单元/集成测试,并记录 issue #15。

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant