test: pin git init to 'main' in test setup (fix Linux-CI branch-group failures)
Git defaults the initial branch to 'master' unless init.defaultBranch is set — true on Linux CI runners but typically overridden to 'main' on developer macOS machines. That host gap made git-worktree tests assuming 'main' (the shared-branch-group reliability suite in engine shard 2/2) pass locally but fail only in CI with 'fatal: path ... does not exist in main'. Set init.defaultBranch=main for every test process via GIT_CONFIG_* env vars in the shared core test setup (inherited by all child git invocations, without mutating the developer's global config). Appends rather than clobbers any pre-existing GIT_CONFIG_COUNT. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,20 @@ const BLOCKED_TEST_CLI_PATTERN =
|
||||
|
||||
const originalCwd = process.cwd.bind(process);
|
||||
|
||||
// Pin `git init` to the `main` branch for every test process. Git defaults the
|
||||
// initial branch to `master` unless `init.defaultBranch` is set — true on Linux
|
||||
// CI runners but usually overridden to `main` on developer macOS machines. That
|
||||
// host gap silently broke git-worktree tests that assume `main` (e.g. the
|
||||
// shared-branch-group reliability suite) in CI only. These GIT_CONFIG_* env
|
||||
// vars apply the setting to all child git invocations without mutating the
|
||||
// developer's global config. Appended (not clobbered) if a count already exists.
|
||||
(() => {
|
||||
const existing = Number.parseInt(process.env.GIT_CONFIG_COUNT ?? "0", 10) || 0;
|
||||
process.env[`GIT_CONFIG_KEY_${existing}`] = "init.defaultBranch";
|
||||
process.env[`GIT_CONFIG_VALUE_${existing}`] = "main";
|
||||
process.env.GIT_CONFIG_COUNT = String(existing + 1);
|
||||
})();
|
||||
|
||||
function ensureValidCwd(): string {
|
||||
try {
|
||||
return originalCwd();
|
||||
|
||||
Reference in New Issue
Block a user