Skip to content

Commit 9a36d31

Browse files
committed
test(server): pass git file protocol through HostProcess.Environment
1 parent a5b613b commit 9a36d31

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import * as Result from "effect/Result";
2121
import * as Scope from "effect/Scope";
2222
import * as Stream from "effect/Stream";
2323
import * as TestClock from "effect/testing/TestClock";
24+
import * as HostProcess from "@t3tools/shared/HostProcess";
2425
import { ChildProcessSpawner } from "effect/process";
2526
import { expect } from "vite-plus/test";
2627
import type {
@@ -5233,20 +5234,6 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
52335234
"checks out the submodules of the head an existing PR branch moves onto (head %s one)",
52345235
(headChange) =>
52355236
Effect.gen(function* () {
5236-
// Git refuses `file:` submodule transports by default (CVE-2022-39253) and ignores
5237-
// repo-level config for it, so a local fixture needs the env allowance.
5238-
const previousAllowedProtocol = process.env.GIT_ALLOW_PROTOCOL;
5239-
process.env.GIT_ALLOW_PROTOCOL = "file";
5240-
yield* Effect.addFinalizer(() =>
5241-
Effect.sync(() => {
5242-
if (previousAllowedProtocol === undefined) {
5243-
delete process.env.GIT_ALLOW_PROTOCOL;
5244-
} else {
5245-
process.env.GIT_ALLOW_PROTOCOL = previousAllowedProtocol;
5246-
}
5247-
}),
5248-
);
5249-
52505237
const submoduleDir = yield* makeTempDir("t3code-git-submodule-");
52515238
yield* initRepo(submoduleDir);
52525239
const repoDir = yield* makeTempDir("t3code-git-manager-");
@@ -5305,7 +5292,19 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
53055292
);
53065293
expect((yield* runGit(worktreePath, ["status", "--porcelain"])).stdout).toBe("");
53075294
expect(result).toMatchObject({ isOnPullRequestHead: true });
5308-
}),
5295+
}).pipe(
5296+
// Git refuses `file:` submodule transports by default (CVE-2022-39253) and ignores
5297+
// repo-level config for it, so a local fixture needs the env allowance.
5298+
(effect) =>
5299+
Effect.flatMap(HostProcess.Environment, (env) =>
5300+
effect.pipe(
5301+
Effect.provideService(HostProcess.Environment, {
5302+
...env,
5303+
GIT_ALLOW_PROTOCOL: "file",
5304+
}),
5305+
),
5306+
),
5307+
),
53095308
);
53105309

53115310
it.effect("refreshes a reused PR worktree onto the updated pull request head", () =>

0 commit comments

Comments
 (0)