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:
@@ -65,6 +65,24 @@ func TestGitActions(t *testing.T) {
|
||||
t.Fatalf("a.txt = %q, want restored to \"one\"", got)
|
||||
}
|
||||
|
||||
// Create a branch (switches to it), then switch back to main.
|
||||
if _, err := svc.GitCreateBranch(ctx, activity.ActorUser, repoPath, "feature-x"); err != nil {
|
||||
t.Fatalf("GitCreateBranch: %v", err)
|
||||
}
|
||||
if st, _ := svc.GetRepo(repoPath); st.Branch != "feature-x" {
|
||||
t.Fatalf("branch = %q, want feature-x", st.Branch)
|
||||
}
|
||||
if _, err := svc.GitCheckout(ctx, activity.ActorUser, repoPath, "main"); err != nil {
|
||||
t.Fatalf("GitCheckout: %v", err)
|
||||
}
|
||||
if st, _ := svc.GetRepo(repoPath); st.Branch != "main" {
|
||||
t.Fatalf("branch = %q, want main", st.Branch)
|
||||
}
|
||||
// Creating an existing branch fails.
|
||||
if _, err := svc.GitCreateBranch(ctx, activity.ActorUser, repoPath, "feature-x"); err == nil {
|
||||
t.Fatalf("expected error creating an existing branch")
|
||||
}
|
||||
|
||||
// The feed recorded the successful actions.
|
||||
kinds := map[string]bool{}
|
||||
for _, e := range feed.Events(0) {
|
||||
|
||||
Reference in New Issue
Block a user