Skip to content

Commit 8478e5e

Browse files
authored
🤖 fix: initialize git repos in e2e fixtures (#868)
The e2e test fixtures created directories but didn't run `git init`, causing `listBranches()` to fail with 'Not a git repository' errors. These errors were logged but didn't fail tests since the tests don't rely on branch-loading functionality - they were just noise in the CI output. **Fix:** run `git init -q` for both projectPath and workspacePath so the fixtures behave like real projects. _Generated with `mux`_
1 parent f4c4d3c commit 8478e5e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/e2e/utils/demoProject.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs";
22
import path from "path";
3+
import { spawnSync } from "child_process";
34
import { Config } from "../../../src/node/config";
45

56
export interface DemoProjectConfig {
@@ -49,6 +50,16 @@ export function prepareDemoProject(
4950
fs.mkdirSync(workspacePath, { recursive: true });
5051
fs.mkdirSync(sessionsDir, { recursive: true });
5152

53+
// Initialize git repos with an initial commit so git commands work properly.
54+
// Empty repos cause errors like "fatal: ref HEAD is not a symbolic ref" when
55+
// detecting the default branch.
56+
for (const repoPath of [projectPath, workspacePath]) {
57+
spawnSync("git", ["init", "-q"], { cwd: repoPath });
58+
spawnSync("git", ["config", "user.email", "test@example.com"], { cwd: repoPath });
59+
spawnSync("git", ["config", "user.name", "Test"], { cwd: repoPath });
60+
spawnSync("git", ["commit", "--allow-empty", "-q", "-m", "init"], { cwd: repoPath });
61+
}
62+
5263
// E2E tests use legacy workspace ID format to test backward compatibility.
5364
// Production code now uses generateStableId() for new workspaces.
5465
const config = new Config(rootDir);

0 commit comments

Comments
 (0)