Skip to content

Commit eb76b4c

Browse files
committed
fix(server): treat untracked review paths literally
1 parent d63fc8a commit eb76b4c

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,24 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
898898
}),
899899
);
900900

901+
it.effect("keeps untracked filenames with pathspec magic in the review", () =>
902+
Effect.gen(function* () {
903+
const cwd = yield* makeTmpDir();
904+
yield* initRepoWithCommit(cwd);
905+
const driver = yield* GitVcsDriver.GitVcsDriver;
906+
yield* writeTextFile(cwd, ":(exclude)after.ts", "literal pathspec contents\n");
907+
yield* writeTextFile(cwd, "ordinary.ts", "ordinary contents\n");
908+
const indexBefore = yield* git(cwd, ["ls-files", "--stage"]);
909+
910+
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
911+
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
912+
913+
assert.include(diff, "+literal pathspec contents");
914+
assert.include(diff, "+ordinary contents");
915+
assert.strictEqual(yield* git(cwd, ["ls-files", "--stage"]), indexBefore);
916+
}),
917+
);
918+
901919
it.effect("detects an unstaged rename with edits without mutating a split index", () =>
902920
Effect.gen(function* () {
903921
const cwd = yield* makeTmpDir();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
23532353
cwd,
23542354
[
23552355
...tempIndexConfig,
2356+
"--literal-pathspecs",
23562357
"add",
23572358
"--intent-to-add",
23582359
"--pathspec-from-file=-",

0 commit comments

Comments
 (0)