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:
2026-09-20 17:27:58 -04:00
parent e59d5bbd29
commit e1999bcf21
10 changed files with 136 additions and 14 deletions
+12
View File
@@ -155,6 +155,18 @@ func (c *CLI) DiscardAll(ctx context.Context, dir string) (string, error) {
return c.run(ctx, dir, "reset", "--hard", "HEAD")
}
// Checkout switches to an existing branch. Git refuses if uncommitted changes
// would be overwritten, so this is not destructive — the error is surfaced.
func (c *CLI) Checkout(ctx context.Context, dir, branch string) (string, error) {
return c.run(ctx, dir, "checkout", branch)
}
// CreateBranch creates a new branch from the current HEAD and switches to it
// (git checkout -b). Fails if the branch already exists.
func (c *CLI) CreateBranch(ctx context.Context, dir, name string) (string, error) {
return c.run(ctx, dir, "checkout", "-b", name)
}
// Branch is a local branch and its upstream, if any.
type Branch struct {
Name string `json:"name"`