TypeScript
fix(server): review diffs keep working with untracked files outside the sparse cone (#29880)
Alex Southwell54223c32e07f
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex 922d14f2682..1cecf781bf7 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -2489,6 +2489,27 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {}),);+ it.effect("reviews untracked files outside the sparse-checkout cone", () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;+ yield* writeTextFile(cwd, "excluded/tracked.ts", "tracked\n");+ yield* git(cwd, ["add", "excluded/tracked.ts"]);+ yield* git(cwd, ["commit", "-m", "add excluded directory"]);+ yield* git(cwd, ["sparse-checkout", "set", "--cone", "included"]);+ yield* writeTextFile(cwd, "excluded/new.ts", "outside the cone\n");++ const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });++ const source = preview.sources.find((candidate) => candidate.kind === "working-tree")!;+ assert.deepStrictEqual(source.files, [+ { path: "excluded/new.ts", previousPath: null, additions: 1, deletions: 0 },+ ]);+ assert.include(source.diff, "+outside the cone");+ }),+ );+it.effect("detects an unstaged rename with edits without mutating a split index", () =>Effect.gen(function* () {const cwd = yield* makeTmpDir();diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex 7b8d34df8cb..107544eacc8 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -3087,6 +3087,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*// Avoid redundant tracked-entry pathspec matching in this disposable index."-c","core.preloadIndex=false",+ // Sparse checkout refuses to add untracked files outside the cone, failing the whole review.+ "-c",+ "core.sparseCheckout=false","--literal-pathspecs","add","--intent-to-add",