From 5530e9154b164f19151e59d38a3fc99b6512570a Mon Sep 17 00:00:00 2001 From: Story Crater Bot <19826264+Riotpiaole@users.noreply.github.com> Date: Sat, 22 Aug 2026 01:03:02 -0700 Subject: [PATCH] fix(tests): create main branch after initial commit for worktree tests Tests were failing because git worktree add -b branch worktree origin/main requires origin/main to exist. Now all test setups create main branch after initial commit so cloned repos have the expected branch. --- tests/git_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/git_test.go b/tests/git_test.go index 790318a..0ac7ef8 100644 --- a/tests/git_test.go +++ b/tests/git_test.go @@ -47,6 +47,12 @@ func TestGitCloneAndFetch(t *testing.T) { t.Fatalf("git commit failed: %v", err) } + // Create main branch (required for worktree operations) + cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main") + if err := cmd.Run(); err != nil { + t.Fatalf("git checkout -b main failed: %v", err) + } + // Test clone into empty path ctx := context.Background() err := action.CloneRepoActivity(ctx, action.CloneRepoInput{ @@ -124,6 +130,12 @@ func TestGitWorktreeAdd(t *testing.T) { t.Fatalf("git commit failed: %v", err) } + // Create main branch (required for worktree operations) + cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main") + if err := cmd.Run(); err != nil { + t.Fatalf("git checkout -b main failed: %v", err) + } + // Clone the repo ctx := context.Background() err := action.CloneRepoActivity(ctx, action.CloneRepoInput{ @@ -186,6 +198,12 @@ func TestGitCommit(t *testing.T) { t.Fatalf("git commit failed: %v", err) } + // Create main branch (required for worktree operations) + cmd = exec.Command("git", "-C", sourceDir, "checkout", "-b", "main") + if err := cmd.Run(); err != nil { + t.Fatalf("git checkout -b main failed: %v", err) + } + // Clone the repo ctx := context.Background() err := action.CloneRepoActivity(ctx, action.CloneRepoInput{