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
20 changes: 18 additions & 2 deletions apps/server/src/vcs/GitVcsDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,25 @@ it.effect.each([
change: ({ git, checkpointRef }: UntrackedBlobChange) =>
git(["update-ref", "-d", checkpointRef]).pipe(Effect.andThen(git(["prune", "--expire=now"]))),
},
...(HostProcess.Platform.defaultValue() === "win32"
? []
: [
{
name: "it became ignored under a name that looks like a git pathspec",
file: ":large.txt",
reuses: false,
change: ({ write }: UntrackedBlobChange) => write(".gitignore", ":large.txt\n"),
},
{
name: "its name looks like git pathspec magic",
file: ":(magic)",
reuses: true,
change: () => Effect.void,
},
]),
])(
"checkpoint capture skips hashing an untracked file only while a fresh hash would match: $name",
({ reuses, change, during }) =>
({ file = "nested/large.txt", reuses, change, during }) =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
Expand Down Expand Up @@ -877,7 +893,7 @@ it.effect.each([
const write = (relativePath: string, contents: string) =>
fs.writeFileString(path.join(cwd, relativePath), contents);
yield* fs.makeDirectory(path.join(cwd, "nested"));
yield* write("nested/large.txt", "line\r\n".repeat(3 * 1024 * 1024));
yield* write(file, "line\r\n".repeat(3 * 1024 * 1024));
// Only files left alone for a few seconds before a capture are remembered.
yield* TestClock.adjust("36500 days");
yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef });
Expand Down
7 changes: 5 additions & 2 deletions apps/server/src/vcs/checkpointUntrackedBlobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export const make = (
const paths = [...blobs.map((blob) => blob.path), ...snapshot.pending];
if (paths.length === 0) return NOTHING;
const unchecked = Effect.succeed({ exitCode: 1, stdout: "" });
const stdin = `${blobs.map((blob) => `${blob.path}\0`).join("")}`;
// ./ avoids leading : pathspec magic; check-ignore rejects --literal-pathspecs.
const stdin = blobs.map((blob) => `./${blob.path}\0`).join("");
const [config, attributes, ignored, objects] = yield* Effect.all(
[
readConfig(input.cwd),
Expand Down Expand Up @@ -290,7 +291,9 @@ export const make = (
attributes: new Map(paths.map((entryPath, index) => [entryPath, attributes[index]])),
};
if (config !== snapshot.config || ignored.exitCode > 1) return { reused: [], before };
const ignoredPaths = new Set(ignored.stdout.split("\0"));
const ignoredPaths = new Set(
ignored.stdout.split("\0").map((entryPath) => entryPath.replace(/^\.\//, "")),
);
const present = new Set(objects.stdout.split("\n"));
blobs = blobs.filter(
(blob, index) =>
Expand Down
Loading