Skip to content

Commit 66d2ed4

Browse files
riley-wvclaude
andcommitted
test(server): isolate workspace fixture git commands from caller repo
Git hooks export GIT_DIR, GIT_INDEX_FILE and related variables. The fixture helper inherited them, so commands like the submodule test's commit could target the caller's repository. Unset repository-location variables for every fixture git command. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 497c515 commit 66d2ed4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/server/src/workspace/WorkspaceEntries.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ function writeTextFile(
5656
});
5757
}
5858

59+
// Git hooks export repository-location variables; unset them so fixtures only touch temp repos.
60+
const isolatedGitEnv: NodeJS.ProcessEnv = {
61+
GIT_DIR: undefined,
62+
GIT_WORK_TREE: undefined,
63+
GIT_INDEX_FILE: undefined,
64+
GIT_OBJECT_DIRECTORY: undefined,
65+
GIT_ALTERNATE_OBJECT_DIRECTORIES: undefined,
66+
GIT_COMMON_DIR: undefined,
67+
};
68+
5969
const git = (cwd: string, args: ReadonlyArray<string>, env?: NodeJS.ProcessEnv) =>
6070
Effect.gen(function* () {
6171
const process = yield* VcsProcess.VcsProcess;
@@ -64,7 +74,7 @@ const git = (cwd: string, args: ReadonlyArray<string>, env?: NodeJS.ProcessEnv)
6474
command: "git",
6575
cwd,
6676
args,
67-
...(env ? { env } : {}),
77+
env: { ...env, ...isolatedGitEnv },
6878
timeoutMs: 10_000,
6979
});
7080
return result.stdout.trim();
@@ -352,7 +362,6 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
352362
it.effect("indexes initialized submodule files without their gitlink metadata", () =>
353363
Effect.gen(function* () {
354364
const identity = {
355-
...process.env,
356365
GIT_AUTHOR_NAME: "T3 Test",
357366
GIT_AUTHOR_EMAIL: "[email protected]",
358367
GIT_COMMITTER_NAME: "T3 Test",

0 commit comments

Comments
 (0)