TypeScript
fix(server): turn checkpoints keep LF files when core.safecrlf is true (#29826)
Alex Southwell940afd65e059
diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.tsindex fd85564a7da..fed1c484d0d 100644--- a/apps/server/src/vcs/GitVcsDriver.test.ts+++ b/apps/server/src/vcs/GitVcsDriver.test.ts@@ -323,6 +323,26 @@ it.effect("checkpoint capture still fails when a clean filter rejects a file", (}).pipe(Effect.scoped, Effect.provide(layerGitContract)),);+it.effect("checkpoint capture keeps LF files that core.safecrlf would refuse to commit", () =>+ Effect.gen(function* () {+ const fileSystem = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const driver = yield* GitVcsDriver.makeVcsDriverShape();+ const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-checkpoint-safecrlf-" });+ const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd);+ yield* fileSystem.writeFileString(path.join(cwd, ".gitattributes"), "*.txt text eol=crlf\n");+ yield* git(["config", "core.safecrlf", "true"]);+ yield* fileSystem.writeFileString(path.join(cwd, "untracked.txt"), "new\n");+ const originalIndex = yield* fileSystem.readFile(path.join(cwd, ".git", "index"));++ yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef });++ assert.strictEqual((yield* git(["show", `${checkpointRef}:file.txt`])).stdout, "unstaged\n");+ assert.strictEqual((yield* git(["show", `${checkpointRef}:untracked.txt`])).stdout, "new\n");+ assert.deepEqual(yield* fileSystem.readFile(path.join(cwd, ".git", "index")), originalIndex);+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),+);+it.effect("checkpoint capture refuses a truncated nested repository listing", () =>Effect.gen(function* () {const fs = yield* FileSystem.FileSystem;diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.tsindex d3ecfcfa95d..42459d8450a 100644--- a/apps/server/src/vcs/GitVcsDriver.ts+++ b/apps/server/src/vcs/GitVcsDriver.ts@@ -1168,6 +1168,9 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (...indexConfig,...durableWrite,...longPaths,+ // safecrlf=true refuses LF files under CRLF conversion; capture them as Git's default does.+ "-c",+ "core.safecrlf=false","add",...(sparseCheckout ? ["--sparse"] : []),// add -A rejects ignored directories even when they contain tracked files.