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
57 changes: 32 additions & 25 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2308,33 +2308,40 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("keeps tracked changes visible when untracked discovery fails", () =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {
if (!ChildProcess.isStandardCommand(command)) {
return Effect.die("expected a standard Git command");
}
return command.args[0] === "ls-files" && command.args[1] === "--others"
? Effect.succeed(makeNonRepositoryHandle())
: delegate.spawn(command);
});
const driver = yield* makeGitVcsDriverCore().pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),
Effect.provide(layerServerConfig),
);
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd).pipe(
Effect.provideService(GitVcsDriver.GitVcsDriver, driver),
);
yield* writeTextFile(cwd, "README.md", "# tracked change\n");
it.effect.each(["fails", "exceeds the output limit"] as const)(
"keeps tracked changes visible when untracked discovery %s",
(scenario) =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {
if (!ChildProcess.isStandardCommand(command)) {
return Effect.die("expected a standard Git command");
}
if (command.args[0] !== "ls-files" || command.args[1] !== "--others") {
return delegate.spawn(command);
}
return Effect.succeed(
scenario === "fails"
? makeNonRepositoryHandle()
: makeSuccessfulHandle("a".repeat(16 * 1024 * 1024 + 1)),
);
});
const driver = yield* makeGitVcsDriverCore().pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),
Effect.provide(layerServerConfig),
);
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd).pipe(
Effect.provideService(GitVcsDriver.GitVcsDriver, driver),
);
yield* writeTextFile(cwd, "README.md", "# tracked change\n");

const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";

assert.include(diff, "-# test");
assert.include(diff, "+# tracked change");
}),
assert.include(diff, "-# test");
assert.include(diff, "+# tracked change");
}),
);

it.effect("preserves a staged deletion when the removed path still exists", () =>
Expand Down
7 changes: 1 addition & 6 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3060,12 +3060,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
cwd,
["ls-files", "--others", "--exclude-standard", "-z", "--", ...pathArgs],
{ maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
).pipe(
Effect.catchIf(
(error) => error.outputLength === undefined,
() => Effect.succeed(null),
),
);
).pipe(Effect.orElseSucceed(() => null));
if (untracked === null) return null;
const paths = splitNullSeparatedGitStdoutPaths(untracked).filter(
(candidate) => onlyPath === undefined || candidate === onlyPath,
Expand Down
Loading