Skip to content
Open
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
58 changes: 30 additions & 28 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,36 +1566,38 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("keeps untracked filenames with pathspec magic in the review", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd);
const driver = yield* GitVcsDriver.GitVcsDriver;
yield* writeTextFile(cwd, ":(exclude)after.ts", "literal pathspec contents\n");
yield* writeTextFile(cwd, "ordinary.ts", "ordinary contents\n");
const indexBefore = yield* git(cwd, ["ls-files", "--stage"]);
it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
"keeps untracked filenames with pathspec magic in the review",
() =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd);
const driver = yield* GitVcsDriver.GitVcsDriver;
yield* writeTextFile(cwd, ":(exclude)after.ts", "literal pathspec contents\n");
yield* writeTextFile(cwd, "ordinary.ts", "ordinary contents\n");
const indexBefore = yield* git(cwd, ["ls-files", "--stage"]);

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, "+literal pathspec contents");
assert.include(diff, "+ordinary contents");
const scoped = yield* driver.getReviewDiffPreview({
cwd,
file: {
path: ":(exclude)after.ts",
previousPath: null,
sourceKind: "working-tree",
},
});
const scopedSource = scoped.sources.find((source) => source.kind === "working-tree")!;
assert.deepStrictEqual(scopedSource.files, [
{ path: ":(exclude)after.ts", previousPath: null, additions: 1, deletions: 0 },
]);
assert.include(scopedSource.diff, "+literal pathspec contents");
assert.notInclude(scopedSource.diff, "ordinary.ts");
assert.strictEqual(yield* git(cwd, ["ls-files", "--stage"]), indexBefore);
}),
assert.include(diff, "+literal pathspec contents");
assert.include(diff, "+ordinary contents");
const scoped = yield* driver.getReviewDiffPreview({
cwd,
file: {
path: ":(exclude)after.ts",
previousPath: null,
sourceKind: "working-tree",
},
});
const scopedSource = scoped.sources.find((source) => source.kind === "working-tree")!;
assert.deepStrictEqual(scopedSource.files, [
{ path: ":(exclude)after.ts", previousPath: null, additions: 1, deletions: 0 },
]);
assert.include(scopedSource.diff, "+literal pathspec contents");
assert.notInclude(scopedSource.diff, "ordinary.ts");
assert.strictEqual(yield* git(cwd, ["ls-files", "--stage"]), indexBefore);
}),
);

it.effect("detects an unstaged rename with edits without mutating a split index", () =>
Expand Down
Loading