Skip to content
Merged
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
49 changes: 49 additions & 0 deletions apps/server/src/vcs/VcsProcess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,55 @@ describe("VcsProcess.run", () => {
}),
);

// Without LANG, macOS Git follows the system language, as in an app launched from Finder.
it.effect("reads Git failures in English when Git would follow the system language", () =>
Effect.gen(function* () {
let attempts = 0;
const service = yield* VcsProcess.make.pipe(
Effect.provideService(
ProcessRunner.ProcessRunner,
ProcessRunner.ProcessRunner.of({
run: (input) =>
Effect.sync(() => {
attempts += 1;
return {
stdout: "",
stderr:
attempts % 2 === 0
? ""
: input.env?.LANGUAGE === "C"
? "fatal: Unable to create '/private/repo/.git/index.lock': File exists.\n"
: "致命錯誤: 無法建立「/private/repo/.git/index.lock」:File exists。\n",
code: ChildProcessSpawner.ExitCode(attempts % 2 === 0 ? 0 : 128),
timedOut: false,
stdoutTruncated: false,
stderrTruncated: false,
stdoutInvalidUtf8: false,
stderrInvalidUtf8: false,
};
}),
}),
),
);

const capture = yield* service
.run({
...baseInput,
operation: VcsProcess.CHECKPOINT_CAPTURE_OPERATION,
args: ["add", "--all"],
})
.pipe(Effect.exit, Effect.forkChild({ startImmediately: true }));
yield* TestClock.adjust("1 second");
expect(Exit.isSuccess(yield* Fiber.join(capture))).toBe(true);
expect(attempts).toBe(2);

attempts = 0;
const error = yield* Effect.flip(service.run(baseInput));
assert.instanceOf(error, VcsProcessExitError);
expect(error.detail).toBe(VcsProcess.GIT_INDEX_LOCKED_DETAIL);
}),
);

it.effect.each([
{
stderr: "fatal: fsync error on '.git/objects/a5/tmp_obj_Pseg66': Operation not supported",
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/vcs/VcsProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ export const make = Effect.gen(function* () {
...(input.stdin !== undefined ? { stdin: input.stdin } : {}),
...(input.onStdoutChunk !== undefined ? { onStdoutChunk: input.onStdoutChunk } : {}),
env: {
// Failures are read by English patterns; without LANG, macOS Git follows the system language.
// LANGUAGE leaves LC_CTYPE, which hooks inherit, alone.
...(input.command === "git" ? { LANGUAGE: "C" } : {}),
...input.env,
...explicitBareRepositoryEnv({ ...process.env, ...input.env }, hostPlatform),
},
Expand Down
Loading