fix(tests): isolate Git fixtures from hook environment

This commit is contained in:
Federico Jaramillo Martinez
2026-07-13 21:11:05 +02:00
parent 926693a2d1
commit cb61146b0a
+2 -1
View File
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path"; import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { beforeEach, afterEach, describe, expect, it } from "vitest"; import { beforeEach, afterEach, describe, expect, it } from "vitest";
import { sanitizedGitEnv } from "./git/gitEnv.js";
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..", ".."); const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
const dockerEntrypoint = join(repoRoot, "docker", "pi-web-docker"); const dockerEntrypoint = join(repoRoot, "docker", "pi-web-docker");
@@ -732,7 +733,7 @@ async function withUnixSocket<T>(socketPath: string, callback: () => Promise<T>)
} }
function cleanProcessEnv(): NodeJS.ProcessEnv { function cleanProcessEnv(): NodeJS.ProcessEnv {
const env = { ...process.env }; const env = sanitizedGitEnv(process.env);
for (const key of Object.keys(env)) { for (const key of Object.keys(env)) {
if (key === "COMPOSE_PROJECT_NAME" || key === "DOCKER_GID" || key === "HOSTEXEC_IMAGE" || key === "XDG_DATA_HOME" || key.startsWith("PI_WEB_")) { if (key === "COMPOSE_PROJECT_NAME" || key === "DOCKER_GID" || key === "HOSTEXEC_IMAGE" || key === "XDG_DATA_HOME" || key.startsWith("PI_WEB_")) {
Reflect.deleteProperty(env, key); Reflect.deleteProperty(env, key);