feat(git-graph): commit 行の右クリックメニューに reset --mixed を追加#658
Conversation
intent(git-graph): commit 行から HEAD をその commit に戻す操作を UI で行いたい decision(git-graph): Files/Changes (PR #640) と同じ popover singleton + pointerup once-capture で実装し、light-dismiss 回避規律を共有 decision(git-ops): hash は validateRev + isAllZeroHex で検証し、`git reset --mixed <hash> --` の `--` で pathspec 誤解釈を排除 rejected(git-graph): 確認ダイアログは挟まない。--mixed は working tree を壊さず reflog で復元可能なため最小メニューに倒す constraint(git-graph): branch ref / index の変化は per-worktree FSWatch が gitStatusChange / branchChange で拾うため、reset 後の再描画は既存 watcher に委ね response に追加データを載せない
|
Warning Review limit reached
More reviews will be available in 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughこのPRは git reset --mixed コマンド実行機能を追加します。プロトコルメッセージスキーマとして GitResetMixedRequest・Response を定義し、ネイティブ側で GitOps.resetMixed() メソッドと RpcDispatcher ハンドラーを実装。フロントエンドでは rpcGitResetMixed RPC ラッパーを追加し、useCommitContextMenu コンポーザブルと CommitContextMenu.vue コンポーネントでコンテキストメニュー UI を構築。GitGraphPane でコンテキストメニューイベント処理と pending 管理を統合し、各コミット行の右クリックから reset を実行できるようにしました。 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…cstrings decision(git-graph): useCommitContextMenu.ts と GitGraphPane.vue の light-dismiss 不変条件リストに「pointerdown で pending を reset する経路を追加しない」条項を転記し、移植元 NavigatorPane の 4 条項と揃える constraint(git-graph): pending が積まれた状態で別経路の pointerdown (左 click 等) が来ると pending を即消去し、次の pointerup での消化が起きなくなるため、状態遷移は pointerup のみで完結させる
intent(git-graph): reset --mixed の入口検証と核心の副作用がテストで一度も踏まれていなかった decision(reset-mixed): lsTree integration suite と対称に、入口 reject 4 ケース + 正常系 1 ケースで構成する decision(reset-mixed): 正常系は c1/c2 二段 commit を作り c1 へ reset し、HEAD 移動 / working tree 保持 / index reset の 3 副作用を独立に assert learned(reset-mixed): mixed reset 後の index reset は porcelain の ` M`(working 変更) と `??`(c1 不在ファイルの untracked 化) で観測できる constraint(reset-mixed): nonExistentHash は空 repo だと別経路の fatal になり得るため seed commit を 1 個置いてから reset を呼ぶ
概要
Git Graph の commit 行に右クリック ( control+click ) メニューを追加し、「Reset (mixed) to
<hash>」でその commit へgit reset --mixedを実行できるようにする。背景
これまで Git Graph は commit の閲覧・選択・diff 表示のみで、HEAD を任意の commit に巻き戻す操作は端末で
git resetを打つしかなかった。Files / Changes 行には ( #640 ) で右クリックメニューを導入済みで、同じ popover + light-dismiss 回避パターンが確立している。commit 行にも同じ経路でよく使う git 操作を載せるのが自然な拡張になる。最初の操作として、working tree のファイルを壊さず ( reflog で復元可能 ) branch ref と index だけを動かす
--mixedを選んだ。変更内容
proto ( SSOT )
git_ops.protoにGitResetMixedRequest { dir, hash }/GitResetMixedResponse {}を追加し、buf generateで TS / Swift 生成物を更新proto-ts/src/index.tsのバレル ( 手動 re-export ) に新型を追加native ( Swift )
GitOps.resetMixed(dir:hash:)を追加。lsTreeと同じ規律で hash を検証する ( 空文字 / all-zero hex を reject、validateRevで-始まりの option 注入・非 hex を弾く )。git reset --mixed <hash> --を実行し、--で pathspec 誤解釈を排除RpcDispatcherに/git/resetMixedルートとhandleGitResetMixedを追加renderer ( Vue )
useCommitContextMenu.ts— commit 行専用の popover singleton。menu kind ごとに独立した singleton を持つ popover 設計指針に従うCommitContextMenu.vue— 「Reset (mixed) to here」アクション。snapshot した dir / hash にrpcGitResetMixedを発行し、失敗時はnotify.errorGitGraphPane.vue— commit 行に@contextmenuを追加、pointeruponce-capture リスナーで WebKit の light-dismiss を回避、右クリック時点でdir/hashを snapshot。macOS control+click が button=0 の click として届くため ( webkit bugzilla 52174 )、onRowClickでctrlKey早期 return して選択変更を抑止rpc.tsにrpcGitResetMixedを追加ドキュメント
docs/git.mdの RPC 一覧にrpcGitResetMixedを追記GitGraphPane.vueの<doc>ブロックに右クリックメニューの記述を追加今回は対応しない
reset 前の確認ダイアログ
--mixedは working tree のファイルを書き換えず reflog で復元可能なため、( #640 ) の最小メニューパターンに合わせて確認なしで即実行する。branch ref を動かす操作のため確認を挟みたい要望が出たら別途追加する。reset --soft / --hard
今回は
--mixed1 種類のみ。--hardは working tree を破壊するため、導入するなら確認ダイアログとセットで別途検討する。確認事項