Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2849,12 +2849,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("reads range patches from source without textconv or color", () =>
it.effect("reads range patches from source without textconv, color, or diff.relative", () =>
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, ["config", "color.ui", "always"]);
yield* git(cwd, ["config", "diff.relative", "true"]);
yield* git(cwd, ["checkout", "-b", "feature/range"]);
yield* writeTextFile(cwd, ".gitattributes", "*.doc diff=probe\n");
yield* writeTextFile(cwd, "notes.doc", "source line\n");
Expand All @@ -2864,8 +2865,10 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
yield* git(cwd, ["commit", "-m", "range files"]);
const driver = yield* GitVcsDriver.GitVcsDriver;
const fileSystem = yield* FileSystem.FileSystem;
const projectCwd = `${cwd}/app`;
yield* fileSystem.makeDirectory(projectCwd);

const context = yield* driver.readRangeContext(cwd, initialBranch);
const context = yield* driver.readRangeContext(projectCwd, initialBranch);

assert.include(context.diffPatch, "+source line");
assert.notInclude(context.diffPatch, "converted");
Expand All @@ -2878,7 +2881,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
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"]);
const staged = yield* driver.prepareCommitContext(projectCwd, ["notes.doc"]);
assert.include(staged?.stagedPatch ?? "", "+updated source line");
assert.notInclude(staged?.stagedPatch ?? "", "converted");
assert.notInclude(staged?.stagedPatch ?? "", "\u001b[");
Expand Down
17 changes: 15 additions & 2 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const stagedSummary = yield* runGitStdoutWithOptions(
"GitVcsDriver.prepareCommitContext.stagedSummary",
cwd,
["diff", "--cached", "--name-status"],
// cwd can be a subdirectory; diff.relative would hide changes outside it.
["-c", "diff.relative=false", "diff", "--cached", "--name-status"],
{ env, maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
).pipe(Effect.map((stdout) => stdout.trim()));
if (stagedSummary.length === 0) {
Expand All @@ -2538,6 +2539,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
"GitVcsDriver.prepareCommitContext.stagedPatch",
cwd,
[
"-c",
"diff.relative=false",
"diff",
"--no-color",
"--no-ext-diff",
Expand Down Expand Up @@ -2947,7 +2950,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
runGitStdoutWithOptions(
"GitVcsDriver.readRangeContext.diffStat",
cwd,
["diff", "--stat", "--no-color", "--end-of-options", diffRange],
[
"-c",
"diff.relative=false",
"diff",
"--stat",
"--no-color",
"--end-of-options",
diffRange,
],
{
maxOutputBytes: RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES,
appendTruncationMarker: true,
Expand All @@ -2957,6 +2968,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
"GitVcsDriver.readRangeContext.diffPatch",
cwd,
[
"-c",
"diff.relative=false",
"diff",
"--no-color",
"--no-ext-diff",
Expand Down
Loading