Skip to content

Commit af3de67

Browse files
saphidclaude
authored andcommitted
fix(server): commits and PR text see changes outside a subfolder project under diff.relative
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 692dd9c commit af3de67

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,12 +2849,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
28492849
}),
28502850
);
28512851

2852-
it.effect("reads range patches from source without textconv or color", () =>
2852+
it.effect("reads range patches from source without textconv, color, or diff.relative", () =>
28532853
Effect.gen(function* () {
28542854
const cwd = yield* makeTmpDir();
28552855
const { initialBranch } = yield* initRepoWithCommit(cwd);
28562856
yield* git(cwd, ["config", "diff.probe.textconv", "touch textconv-ran; echo converted"]);
28572857
yield* git(cwd, ["config", "color.ui", "always"]);
2858+
yield* git(cwd, ["config", "diff.relative", "true"]);
28582859
yield* git(cwd, ["checkout", "-b", "feature/range"]);
28592860
yield* writeTextFile(cwd, ".gitattributes", "*.doc diff=probe\n");
28602861
yield* writeTextFile(cwd, "notes.doc", "source line\n");
@@ -2864,8 +2865,10 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
28642865
yield* git(cwd, ["commit", "-m", "range files"]);
28652866
const driver = yield* GitVcsDriver.GitVcsDriver;
28662867
const fileSystem = yield* FileSystem.FileSystem;
2868+
const projectCwd = `${cwd}/app`;
2869+
yield* fileSystem.makeDirectory(projectCwd);
28672870

2868-
const context = yield* driver.readRangeContext(cwd, initialBranch);
2871+
const context = yield* driver.readRangeContext(projectCwd, initialBranch);
28692872

28702873
assert.include(context.diffPatch, "+source line");
28712874
assert.notInclude(context.diffPatch, "converted");
@@ -2878,7 +2881,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
28782881
assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));
28792882

28802883
yield* writeTextFile(cwd, "notes.doc", "updated source line\n");
2881-
const staged = yield* driver.prepareCommitContext(cwd, ["notes.doc"]);
2884+
const staged = yield* driver.prepareCommitContext(projectCwd, ["notes.doc"]);
28822885
assert.include(staged?.stagedPatch ?? "", "+updated source line");
28832886
assert.notInclude(staged?.stagedPatch ?? "", "converted");
28842887
assert.notInclude(staged?.stagedPatch ?? "", "\u001b[");

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
25242524
const stagedSummary = yield* runGitStdoutWithOptions(
25252525
"GitVcsDriver.prepareCommitContext.stagedSummary",
25262526
cwd,
2527-
["diff", "--cached", "--name-status"],
2527+
// cwd can be a subdirectory; diff.relative would hide changes outside it.
2528+
["-c", "diff.relative=false", "diff", "--cached", "--name-status"],
25282529
{ env, maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
25292530
).pipe(Effect.map((stdout) => stdout.trim()));
25302531
if (stagedSummary.length === 0) {
@@ -2538,6 +2539,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
25382539
"GitVcsDriver.prepareCommitContext.stagedPatch",
25392540
cwd,
25402541
[
2542+
"-c",
2543+
"diff.relative=false",
25412544
"diff",
25422545
"--no-color",
25432546
"--no-ext-diff",
@@ -2947,7 +2950,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
29472950
runGitStdoutWithOptions(
29482951
"GitVcsDriver.readRangeContext.diffStat",
29492952
cwd,
2950-
["diff", "--stat", "--no-color", "--end-of-options", diffRange],
2953+
[
2954+
"-c",
2955+
"diff.relative=false",
2956+
"diff",
2957+
"--stat",
2958+
"--no-color",
2959+
"--end-of-options",
2960+
diffRange,
2961+
],
29512962
{
29522963
maxOutputBytes: RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES,
29532964
appendTruncationMarker: true,
@@ -2957,6 +2968,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
29572968
"GitVcsDriver.readRangeContext.diffPatch",
29582969
cwd,
29592970
[
2971+
"-c",
2972+
"diff.relative=false",
29602973
"diff",
29612974
"--no-color",
29622975
"--no-ext-diff",

0 commit comments

Comments
 (0)