Slice 9: git_checkout and create_branch (menu + MCP)
git boundary Checkout/CreateBranch; service GitCheckout/GitCreateBranch (activity detail names the branch; gitAction takes an ok-detail). HTTP /api/repo/git ops checkout + create-branch (branch field). MCP tools git_checkout and create_branch. <repo-menu> gains Switch branch… and New branch… (prompt for name). Service test covers create+switch and existing-branch failure. Checkout is not destructive - git refuses if it would overwrite changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,8 @@ const ITEMS = [
|
||||
{ cmd: 'push', label: 'Publish', hint: 'push' },
|
||||
{ cmd: 'fetch', label: 'Check for updates', hint: 'fetch' },
|
||||
{ cmd: 'commit', label: 'Save my work…', hint: 'commit' },
|
||||
{ cmd: 'checkout', label: 'Switch branch…', hint: 'checkout' },
|
||||
{ cmd: 'newbranch', label: 'New branch…', hint: 'branch' },
|
||||
{ sep: true },
|
||||
{ cmd: 'active', label: 'Set as active project' },
|
||||
{ cmd: 'handoff', label: 'Ask Claude to switch here' },
|
||||
@@ -91,6 +93,16 @@ class RepoMenu extends HTMLElement {
|
||||
if (msg && msg.trim()) await this.#git('commit', { message: msg });
|
||||
break;
|
||||
}
|
||||
case 'checkout': {
|
||||
const b = window.prompt(`Switch ${name} to which existing branch?`);
|
||||
if (b && b.trim()) await this.#git('checkout', { branch: b.trim() });
|
||||
break;
|
||||
}
|
||||
case 'newbranch': {
|
||||
const b = window.prompt(`New branch name in ${name}:`);
|
||||
if (b && b.trim()) await this.#git('create-branch', { branch: b.trim() });
|
||||
break;
|
||||
}
|
||||
case 'discard': {
|
||||
const ok = window.confirm(
|
||||
`Discard ALL uncommitted changes in ${name}?\n\n` +
|
||||
|
||||
@@ -11,10 +11,11 @@ event. Safe commands run on click; the destructive one confirms first (§1.4).
|
||||
- **Listens:** `repo:contextmenu` on `document` — `detail: { repo, x, y }`
|
||||
(dispatched by `<repo-list>` on right-click). Shows the menu at (x, y).
|
||||
- **Commands → endpoints:**
|
||||
- Get latest / Publish / Check for updates / Save my work… / Discard all
|
||||
changes… → `POST /api/repo/git {path, op, message?}` (op: pull/push/fetch/
|
||||
commit/discard). "Save my work…" prompts for a message; "Discard all
|
||||
changes…" confirms (destructive).
|
||||
- Get latest / Publish / Check for updates / Save my work… / Switch branch… /
|
||||
New branch… / Discard all changes… → `POST /api/repo/git {path, op,
|
||||
message?, branch?}` (op: pull/push/fetch/commit/checkout/create-branch/
|
||||
discard). "Save my work…" prompts for a message; "Switch branch…"/"New
|
||||
branch…" prompt for the branch; "Discard all changes…" confirms (destructive).
|
||||
- Set as active project → `POST /api/active-project`.
|
||||
- Ask Claude to switch here → `POST /api/switch` (the handoff request).
|
||||
- Copy path → clipboard.
|
||||
@@ -23,6 +24,8 @@ event. Safe commands run on click; the destructive one confirms first (§1.4).
|
||||
## History
|
||||
- 2026-09-20: created — slice 6; plain-language git commands + coordination
|
||||
actions, backed by the shared service layer (same ops Claude gets via MCP).
|
||||
- 2026-09-20: added "Switch branch…" (checkout) and "New branch…" (create-branch),
|
||||
both prompting for the branch name (slice 9).
|
||||
|
||||
## Notes / gotchas
|
||||
- Results aren't shown inline; they appear in `<activity-feed>` (each op records a
|
||||
|
||||
Reference in New Issue
Block a user