Skip to content
TypeScript

fix(server): generated PR text reads source diffs instead of textconv output (#22503)

Victor Vogel655165d5f805
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.ts
index 8363e16c324..a89863d4f7f 100644
--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts
+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts
@@ -2577,6 +2577,39 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);
+ it.effect("reads range patches from source without running textconv", () =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ const { initialBranch } = yield* initRepoWithCommit(cwd);
+ yield* git(cwd, ["config", "diff.probe.textconv", "touch textconv-ran; echo converted"]);
+ yield* git(cwd, ["checkout", "-b", "feature/range"]);
+ yield* writeTextFile(cwd, ".gitattributes", "*.doc diff=probe\n");
+ yield* writeTextFile(cwd, "notes.doc", "source line\n");
+ yield* writeTextFile(cwd, "plain.txt", "plain line\n");
+ yield* writeTextFile(cwd, "binary.dat", "binary\0data");
+ yield* git(cwd, ["add", "."]);
+ yield* git(cwd, ["commit", "-m", "range files"]);
+ const driver = yield* GitVcsDriver.GitVcsDriver;
+ const fileSystem = yield* FileSystem.FileSystem;
+
+ const context = yield* driver.readRangeContext(cwd, initialBranch);
+
+ assert.include(context.diffPatch, "+source line");
+ assert.notInclude(context.diffPatch, "converted");
+ assert.include(context.diffPatch, "+plain line");
+ assert.include(context.diffPatch, "Binary files /dev/null and b/binary.dat differ");
+ assert.include(context.diffSummary, "notes.doc");
+ assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));
+
+ yield* writeTextFile(cwd, "notes.doc", "updated source line\n");
+ const staged = yield* driver.prepareCommitContext(cwd, ["notes.doc"]);
+ assert.include(staged?.stagedPatch ?? "", "+updated source line");
+ assert.notInclude(staged?.stagedPatch ?? "", "converted");
+ assert.include(staged?.stagedSummary ?? "", "notes.doc");
+ assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));
+ }),
+ );
+
it.effect("loads new and deleted files without reading their missing side", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts
index 71945b0b6f7..bea65a0f42a 100644
--- a/apps/server/src/vcs/GitVcsDriverCore.ts
+++ b/apps/server/src/vcs/GitVcsDriverCore.ts
@@ -2502,7 +2502,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const stagedPatch = yield* runGitStdoutWithOptions(
"GitVcsDriver.prepareCommitContext.stagedPatch",
cwd,
- ["diff", "--no-ext-diff", "--cached", "--patch", "--minimal"],
+ ["diff", "--no-ext-diff", "--no-textconv", "--cached", "--patch", "--minimal"],
{
env,
maxOutputBytes: PREPARED_COMMIT_PATCH_MAX_OUTPUT_BYTES,
@@ -2913,7 +2913,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
runGitStdoutWithOptions(
"GitVcsDriver.readRangeContext.diffPatch",
cwd,
- ["diff", "--no-ext-diff", "--patch", "--minimal", "--end-of-options", diffRange],
+ [
+ "diff",
+ "--no-ext-diff",
+ "--no-textconv",
+ "--patch",
+ "--minimal",
+ "--end-of-options",
+ diffRange,
+ ],
{
maxOutputBytes: RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES,
appendTruncationMarker: true,