Skip to content

Commit 3dcf6aa

Browse files
committed
test(server): drop inherited git URL rewrites from the test git config
gitConfig.setup.ts appends stable settings to GIT_CONFIG_* so every git child in the server tests sees the same config. It kept whatever the shell had already set. Some sandboxed shells set url.https://github.com/.insteadOf there, and git then reports the rewritten URL back for fixture remotes. Git has no setting that cancels an insteadOf, so three tests failed outside CI: one in GitVcsDriver and two in RepositoryIdentityResolver. The setup now rebuilds GIT_CONFIG_* without url.*.insteadOf and url.*.pushInsteadOf entries. Other inherited keys stay. No test assertion changes. Fails before (with the rewrite in the environment): 3 remote URL assertions. Passes after, with the same environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01A1D6J2UMPo7YBWQFvbg1br
1 parent fc82653 commit 3dcf6aa

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

‎apps/server/src/testUtils/gitConfig.setup.ts‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,25 @@ const entries: ReadonlyArray<readonly [key: string, value: string]> = [
88
["init.defaultBranch", "main"],
99
];
1010

11-
const existing = Number(process.env.GIT_CONFIG_COUNT ?? "0");
12-
process.env.GIT_CONFIG_COUNT = String(existing + entries.length);
13-
entries.forEach(([key, value], index) => {
14-
process.env[`GIT_CONFIG_KEY_${existing + index}`] = key;
15-
process.env[`GIT_CONFIG_VALUE_${existing + index}`] = value;
11+
// Inherited url.<base>.insteadOf rewrites change the remote URLs git reports back for fixtures.
12+
// Sandboxed shells inject them through env, and git has no setting that cancels one, so drop them.
13+
const isUrlRewrite = (key: string) => /^url\..+\.(?:push)?insteadof$/i.test(key);
14+
const inherited = Array.from(
15+
{ length: Number(process.env.GIT_CONFIG_COUNT ?? "0") },
16+
(_, index) => {
17+
const entry = [
18+
process.env[`GIT_CONFIG_KEY_${index}`] ?? "",
19+
process.env[`GIT_CONFIG_VALUE_${index}`] ?? "",
20+
] as const;
21+
delete process.env[`GIT_CONFIG_KEY_${index}`];
22+
delete process.env[`GIT_CONFIG_VALUE_${index}`];
23+
return entry;
24+
},
25+
);
26+
27+
const config = [...inherited.filter(([key]) => !isUrlRewrite(key)), ...entries];
28+
process.env.GIT_CONFIG_COUNT = String(config.length);
29+
config.forEach(([key, value], index) => {
30+
process.env[`GIT_CONFIG_KEY_${index}`] = key;
31+
process.env[`GIT_CONFIG_VALUE_${index}`] = value;
1632
});

0 commit comments

Comments
 (0)