Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/e2e/utils/demoProject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs";
import path from "path";
import { spawnSync } from "child_process";
import { Config } from "../../../src/node/config";

export interface DemoProjectConfig {
Expand Down Expand Up @@ -49,6 +50,16 @@ export function prepareDemoProject(
fs.mkdirSync(workspacePath, { recursive: true });
fs.mkdirSync(sessionsDir, { recursive: true });

// Initialize git repos with an initial commit so git commands work properly.
// Empty repos cause errors like "fatal: ref HEAD is not a symbolic ref" when
// detecting the default branch.
for (const repoPath of [projectPath, workspacePath]) {
spawnSync("git", ["init", "-q"], { cwd: repoPath });
spawnSync("git", ["config", "user.email", "test@example.com"], { cwd: repoPath });
spawnSync("git", ["config", "user.name", "Test"], { cwd: repoPath });
spawnSync("git", ["commit", "--allow-empty", "-q", "-m", "init"], { cwd: repoPath });
}

// E2E tests use legacy workspace ID format to test backward compatibility.
// Production code now uses generateStableId() for new workspaces.
const config = new Config(rootDir);
Expand Down