From a07083305a21e7348e40d567c26827af668dd640 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Fri, 17 Jul 2026 15:24:05 +0800 Subject: [PATCH] fix(server): stabilize non-repository Git diagnostics --- apps/server/src/vcs/GitVcsDriverCore.test.ts | 16 ++++++++++++++++ apps/server/src/vcs/GitVcsDriverCore.ts | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.ts index dc58fc2543c..cfe135ed3c8 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.test.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts @@ -78,6 +78,22 @@ const initRepoWithCommit = ( }); it.layer(TestLayer)("GitVcsDriver core integration", (it) => { + describe("process environment", () => { + it.effect("preserves the caller locale for general Git subprocesses", () => + Effect.gen(function* () { + const cwd = yield* makeTmpDir(); + + const locale = yield* git( + cwd, + ["-c", 'alias.print-locale=!printf "%s" "$LC_ALL"', "print-locale"], + { LC_ALL: "zh_CN.UTF-8" }, + ); + + assert.equal(locale, "zh_CN.UTF-8"); + }), + ); + }); + describe("structured errors", () => { it.effect("preserves structured spawn context and the platform cause", () => Effect.gen(function* () { diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts index a406cbce549..76ffe60b336 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.ts @@ -370,6 +370,8 @@ function isNonRepositoryGitStderr(stderr: string): boolean { return stderr.toLowerCase().includes("not a git repository"); } +const NON_REPOSITORY_DETECTION_ENV = { LC_ALL: "C" } as const; + interface Trace2Monitor { readonly env: NodeJS.ProcessEnv; readonly flush: Effect.Effect; @@ -1310,6 +1312,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* ["status", "--porcelain=2", "--branch"], { allowNonZeroExit: true, + env: NON_REPOSITORY_DETECTION_ENV, }, ).pipe( Effect.catchTags({ @@ -1992,6 +1995,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* { timeoutMs: 10_000, allowNonZeroExit: true, + env: NON_REPOSITORY_DETECTION_ENV, }, ).pipe( Effect.catchTags({