Make git tests independent of init.defaultBranch

This commit is contained in:
Mohamed Boudra
2026-02-04 23:56:29 +07:00
parent 32c98536b5
commit 2f3cbe5e84
5 changed files with 14 additions and 14 deletions

View File

@@ -783,7 +783,7 @@ function waitForSignal<T>(
async () => {
const cwd = tmpCwd();
execSync("git init", { cwd, stdio: "pipe" });
execSync("git init -b main", { cwd, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", {
cwd,
stdio: "pipe",

View File

@@ -266,7 +266,7 @@ describe("daemon checkout ship loop", () => {
initGitRepo(repoDir);
const remoteDir = path.join(repoDir, "remote.git");
execSync(`git init --bare ${remoteDir}`, { stdio: "pipe" });
execSync(`git init --bare -b main ${remoteDir}`, { stdio: "pipe" });
execSync(`git remote add origin ${remoteDir}`, { cwd: repoDir, stdio: "pipe" });
execSync("git push -u origin main", { cwd: repoDir, stdio: "pipe" });

View File

@@ -168,7 +168,7 @@ describe("daemon E2E", () => {
// Initialize git repo with clean state
const { execSync } = await import("child_process");
execSync("git init", { cwd, stdio: "pipe" });
execSync("git init -b main", { cwd, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", { cwd, stdio: "pipe" });
execSync("git config user.name 'Test'", { cwd, stdio: "pipe" });
@@ -242,7 +242,7 @@ describe("daemon E2E", () => {
// Initialize git repo
const { execSync } = await import("child_process");
execSync("git init", { cwd, stdio: "pipe" });
execSync("git init -b main", { cwd, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", { cwd, stdio: "pipe" });
execSync("git config user.name 'Test'", { cwd, stdio: "pipe" });
@@ -293,7 +293,7 @@ describe("daemon E2E", () => {
// Initialize git repo with clean state
const { execSync } = await import("child_process");
execSync("git init", { cwd, stdio: "pipe" });
execSync("git init -b main", { cwd, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", { cwd, stdio: "pipe" });
execSync("git config user.name 'Test'", { cwd, stdio: "pipe" });
@@ -365,7 +365,7 @@ describe("daemon E2E", () => {
const repoRoot = tmpCwd();
const { execSync } = await import("child_process");
execSync("git init", { cwd: repoRoot, stdio: "pipe" });
execSync("git init -b main", { cwd: repoRoot, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", {
cwd: repoRoot,
stdio: "pipe",
@@ -439,7 +439,7 @@ describe("daemon E2E", () => {
const repoRoot = tmpCwd();
const { execSync } = await import("child_process");
execSync("git init", { cwd: repoRoot, stdio: "pipe" });
execSync("git init -b main", { cwd: repoRoot, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", {
cwd: repoRoot,
stdio: "pipe",
@@ -526,7 +526,7 @@ describe("daemon E2E", () => {
const cwd = tmpCwd();
const { execSync } = await import("child_process");
execSync("git init", { cwd, stdio: "pipe" });
execSync("git init -b main", { cwd, stdio: "pipe" });
execSync("git config user.email 'test@test.com'", { cwd, stdio: "pipe" });
execSync("git config user.name 'Test'", { cwd, stdio: "pipe" });

View File

@@ -80,7 +80,7 @@ describe("checkout git utilities", () => {
it("exposes hasRemote when origin is configured", async () => {
const remoteDir = join(tempDir, "remote.git");
execSync(`git init --bare ${remoteDir}`);
execSync(`git init --bare -b main ${remoteDir}`);
execSync(`git remote add origin ${remoteDir}`, { cwd: repoDir });
const status = await getCheckoutStatus(repoDir);
@@ -232,7 +232,7 @@ describe("checkout git utilities", () => {
it("merges from the most-ahead base ref (origin/main when it is ahead)", async () => {
const remoteDir = join(tempDir, "remote.git");
execSync(`git init --bare ${remoteDir}`);
execSync(`git init --bare -b main ${remoteDir}`);
execSync(`git remote add origin ${remoteDir}`, { cwd: repoDir });
execSync("git push -u origin main", { cwd: repoDir });
@@ -262,7 +262,7 @@ describe("checkout git utilities", () => {
it("merges from the most-ahead base ref (local main when it is ahead)", async () => {
const remoteDir = join(tempDir, "remote.git");
execSync(`git init --bare ${remoteDir}`);
execSync(`git init --bare -b main ${remoteDir}`);
execSync(`git remote add origin ${remoteDir}`, { cwd: repoDir });
execSync("git push -u origin main", { cwd: repoDir });
@@ -312,7 +312,7 @@ describe("checkout git utilities", () => {
it("pushes the current branch to origin", async () => {
const remoteDir = join(tempDir, "remote.git");
execSync(`git init --bare ${remoteDir}`);
execSync(`git init --bare -b main ${remoteDir}`);
execSync(`git remote add origin ${remoteDir}`, { cwd: repoDir });
execSync("git push -u origin main", { cwd: repoDir });

View File

@@ -25,7 +25,7 @@ describe("createWorktree", () => {
// Create a git repo with an initial commit
execSync(`mkdir -p ${repoDir}`);
execSync("git init", { cwd: repoDir });
execSync("git init -b main", { cwd: repoDir });
execSync("git config user.email 'test@test.com'", { cwd: repoDir });
execSync("git config user.name 'Test'", { cwd: repoDir });
execSync("echo 'hello' > file.txt", { cwd: repoDir });
@@ -265,7 +265,7 @@ describe("paseo worktree manager", () => {
paseoHome = join(tempDir, "paseo-home");
execSync(`mkdir -p ${repoDir}`);
execSync("git init", { cwd: repoDir });
execSync("git init -b main", { cwd: repoDir });
execSync("git config user.email 'test@test.com'", { cwd: repoDir });
execSync("git config user.name 'Test'", { cwd: repoDir });
execSync("echo 'hello' > file.txt", { cwd: repoDir });