Skip to content

Commit da2ee62

Browse files
refactor(server): take the host platform from HostProcess for git config env
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d94ca0b commit da2ee62

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎apps/server/src/project/RepositoryIdentityResolver.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as Layer from "effect/Layer";
1212

1313
import * as ProcessRunner from "../processRunner.ts";
1414
import { explicitBareRepositoryEnv } from "../vcs/VcsProcess.ts";
15+
import * as HostProcess from "@t3tools/shared/HostProcess";
1516

1617
const DEFAULT_REPOSITORY_IDENTITY_CACHE_CAPACITY = 512;
1718
// Background sweeps resolve every project each minute. A long TTL keeps them
@@ -125,7 +126,7 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("RepositoryIdentityResolver.
125126
.run({
126127
command: "git",
127128
args: ["-C", cwd, "rev-parse", "--show-toplevel"],
128-
env: explicitBareRepositoryEnv(process.env),
129+
env: explicitBareRepositoryEnv(process.env, yield* HostProcess.Platform),
129130
timeoutBehavior: "timedOutResult",
130131
})
131132
.pipe(Effect.option);
@@ -148,7 +149,7 @@ const resolveRepositoryIdentityFromCacheKey = Effect.fn(
148149
.run({
149150
command: "git",
150151
args: ["-C", cacheKey, "remote", "-v"],
151-
env: explicitBareRepositoryEnv(process.env),
152+
env: explicitBareRepositoryEnv(process.env, yield* HostProcess.Platform),
152153
timeoutBehavior: "timedOutResult",
153154
})
154155
.pipe(Effect.option);

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
960960
...input.env,
961961
...trace2Monitor.env,
962962
};
963-
const env = { ...baseEnv, ...explicitBareRepositoryEnv(baseEnv) };
963+
const env = { ...baseEnv, ...explicitBareRepositoryEnv(baseEnv, hostPlatform) };
964964
const spawnEnv = { ...env, ...windowsLongPathConfigEnv(hostPlatform, env) };
965965
const resolved = yield* resolveSpawnCommand("git", [], { env: spawnEnv });
966966
// A git.cmd wrapper would need cmd.exe, which cuts multi-line commit

‎apps/server/src/vcs/VcsProcess.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
VcsProcessStdinWriteError,
1919
VcsProcessTimeoutError,
2020
} from "@t3tools/contracts";
21+
import * as HostProcess from "@t3tools/shared/HostProcess";
22+
2123
import * as ProcessRunner from "../processRunner.ts";
2224

2325
export interface VcsProcessInput {
@@ -75,7 +77,7 @@ export const gitConfigEnv = (
7577
env: NodeJS.ProcessEnv,
7678
key: string,
7779
value: string,
78-
platform: NodeJS.Platform = process.platform,
80+
platform: NodeJS.Platform,
7981
): NodeJS.ProcessEnv => {
8082
const countKeys = Object.keys(env).filter((name) =>
8183
platform === "win32" ? name.toUpperCase() === "GIT_CONFIG_COUNT" : name === "GIT_CONFIG_COUNT",
@@ -106,8 +108,8 @@ export const gitConfigEnv = (
106108
* form one, so git started by T3 (or by gh and friends) only opens a bare
107109
* repository named with `--git-dir` or `GIT_DIR`. Git before 2.38 ignores it.
108110
*/
109-
export const explicitBareRepositoryEnv = (env: NodeJS.ProcessEnv) =>
110-
gitConfigEnv(env, "safe.bareRepository", "explicit");
111+
export const explicitBareRepositoryEnv = (env: NodeJS.ProcessEnv, platform: NodeJS.Platform) =>
112+
gitConfigEnv(env, "safe.bareRepository", "explicit", platform);
111113

112114
const classifyNonZeroExit = (command: string, stderr: string): VcsProcessExitFailureKind => {
113115
const normalized = stderr.toLowerCase();
@@ -162,6 +164,7 @@ const isTransientGitExit = (stderr: string) =>
162164

163165
export const make = Effect.gen(function* () {
164166
const processRunner = yield* ProcessRunner.ProcessRunner;
167+
const hostPlatform = yield* HostProcess.Platform;
165168
const vcsProcesses = yield* Semaphore.make(VCS_PROCESS_CONCURRENCY);
166169
const githubProcesses = yield* Semaphore.make(GITHUB_PROCESS_CONCURRENCY);
167170

@@ -181,7 +184,10 @@ export const make = Effect.gen(function* () {
181184
...(input.spawnCwd !== undefined ? { spawnCwd: input.spawnCwd } : {}),
182185
...(input.stdin !== undefined ? { stdin: input.stdin } : {}),
183186
...(input.onStdoutChunk !== undefined ? { onStdoutChunk: input.onStdoutChunk } : {}),
184-
env: { ...input.env, ...explicitBareRepositoryEnv({ ...process.env, ...input.env }) },
187+
env: {
188+
...input.env,
189+
...explicitBareRepositoryEnv({ ...process.env, ...input.env }, hostPlatform),
190+
},
185191
timeout: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,
186192
maxOutputBytes: input.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
187193
outputMode: input.outputMode ?? "truncate",

0 commit comments

Comments
 (0)