Skip to content

Commit 655165d

Browse files
only21milclaudecodexmaria-rcks
authored
fix(server): generated PR text reads source diffs instead of textconv output (#22503)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: GPT-6.1 Sol <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 253acde commit 655165d

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,39 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
25772577
}),
25782578
);
25792579

2580+
it.effect("reads range patches from source without running textconv", () =>
2581+
Effect.gen(function* () {
2582+
const cwd = yield* makeTmpDir();
2583+
const { initialBranch } = yield* initRepoWithCommit(cwd);
2584+
yield* git(cwd, ["config", "diff.probe.textconv", "touch textconv-ran; echo converted"]);
2585+
yield* git(cwd, ["checkout", "-b", "feature/range"]);
2586+
yield* writeTextFile(cwd, ".gitattributes", "*.doc diff=probe\n");
2587+
yield* writeTextFile(cwd, "notes.doc", "source line\n");
2588+
yield* writeTextFile(cwd, "plain.txt", "plain line\n");
2589+
yield* writeTextFile(cwd, "binary.dat", "binary\0data");
2590+
yield* git(cwd, ["add", "."]);
2591+
yield* git(cwd, ["commit", "-m", "range files"]);
2592+
const driver = yield* GitVcsDriver.GitVcsDriver;
2593+
const fileSystem = yield* FileSystem.FileSystem;
2594+
2595+
const context = yield* driver.readRangeContext(cwd, initialBranch);
2596+
2597+
assert.include(context.diffPatch, "+source line");
2598+
assert.notInclude(context.diffPatch, "converted");
2599+
assert.include(context.diffPatch, "+plain line");
2600+
assert.include(context.diffPatch, "Binary files /dev/null and b/binary.dat differ");
2601+
assert.include(context.diffSummary, "notes.doc");
2602+
assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));
2603+
2604+
yield* writeTextFile(cwd, "notes.doc", "updated source line\n");
2605+
const staged = yield* driver.prepareCommitContext(cwd, ["notes.doc"]);
2606+
assert.include(staged?.stagedPatch ?? "", "+updated source line");
2607+
assert.notInclude(staged?.stagedPatch ?? "", "converted");
2608+
assert.include(staged?.stagedSummary ?? "", "notes.doc");
2609+
assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));
2610+
}),
2611+
);
2612+
25802613
it.effect("loads new and deleted files without reading their missing side", () =>
25812614
Effect.gen(function* () {
25822615
const cwd = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
25022502
const stagedPatch = yield* runGitStdoutWithOptions(
25032503
"GitVcsDriver.prepareCommitContext.stagedPatch",
25042504
cwd,
2505-
["diff", "--no-ext-diff", "--cached", "--patch", "--minimal"],
2505+
["diff", "--no-ext-diff", "--no-textconv", "--cached", "--patch", "--minimal"],
25062506
{
25072507
env,
25082508
maxOutputBytes: PREPARED_COMMIT_PATCH_MAX_OUTPUT_BYTES,
@@ -2913,7 +2913,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
29132913
runGitStdoutWithOptions(
29142914
"GitVcsDriver.readRangeContext.diffPatch",
29152915
cwd,
2916-
["diff", "--no-ext-diff", "--patch", "--minimal", "--end-of-options", diffRange],
2916+
[
2917+
"diff",
2918+
"--no-ext-diff",
2919+
"--no-textconv",
2920+
"--patch",
2921+
"--minimal",
2922+
"--end-of-options",
2923+
diffRange,
2924+
],
29172925
{
29182926
maxOutputBytes: RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES,
29192927
appendTruncationMarker: true,

0 commit comments

Comments
 (0)