Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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* () {
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void, never>;
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -1992,6 +1995,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
{
timeoutMs: 10_000,
allowNonZeroExit: true,
env: NON_REPOSITORY_DETECTION_ENV,
},
).pipe(
Effect.catchTags({
Expand Down
Loading