fix(checkpointing): canonicalize repository ownership paths
Resolve symbolic workspace aliases before choosing between the owned Git repository and the shadow checkpoint store. This keeps /var and /private/var representations from splitting checkpoint state on macOS. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
54538c88c7
commit
1bafb7b938
2 files changed
+30
-11
No files matched your search
@@ -114,6 +114,21 @@ it.layer(TestLayer)("CheckpointStore.layer", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("recognizes an owned Git repository through a symbolic path alias", () =>
|
||||
Effect.gen(function* () {
|
||||
const tmp = yield* makeTmpDir();
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const repositoryPath = NodePath.join(tmp, "repository");
|
||||
const aliasPath = NodePath.join(tmp, "repository-alias");
|
||||
yield* fileSystem.makeDirectory(repositoryPath);
|
||||
yield* initRepoWithCommit(repositoryPath);
|
||||
yield* fileSystem.symlink(repositoryPath, aliasPath);
|
||||
const checkpointStore = yield* CheckpointStore.CheckpointStore;
|
||||
|
||||
expect(yield* checkpointStore.isGitRepository(aliasPath)).toBe(true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("treats a standalone project nested under another repository as non-Git", () =>
|
||||
Effect.gen(function* () {
|
||||
const tmp = yield* makeTmpDir();
|
||||
|
||||
@@ -115,6 +115,8 @@ export const make = Effect.gen(function* () {
|
||||
"checkpoints",
|
||||
NodeCrypto.createHash("sha256").update(NodePath.resolve(cwd)).digest("hex"),
|
||||
);
|
||||
const canonicalizeWorkspacePath = (value: string) =>
|
||||
fileSystem.realPath(value).pipe(Effect.orElseSucceed(() => NodePath.resolve(value)));
|
||||
|
||||
const runShadowGit = Effect.fn("CheckpointStore.runShadowGit")(function* (input: {
|
||||
readonly operation: string;
|
||||
@@ -337,22 +339,24 @@ export const make = Effect.gen(function* () {
|
||||
) {
|
||||
const handle = yield* vcsRegistry.detect({ cwd });
|
||||
const workspaceOwnsRepository =
|
||||
handle !== null && NodePath.resolve(handle.repository.rootPath) === NodePath.resolve(cwd);
|
||||
handle !== null &&
|
||||
(yield* canonicalizeWorkspacePath(handle.repository.rootPath)) ===
|
||||
(yield* canonicalizeWorkspacePath(cwd));
|
||||
return workspaceOwnsRepository
|
||||
? (handle.driver.checkpoints ?? shadowCheckpoints)
|
||||
: shadowCheckpoints;
|
||||
});
|
||||
|
||||
const isGitRepository: CheckpointStore["Service"]["isGitRepository"] = (cwd) =>
|
||||
vcsRegistry
|
||||
.detect({ cwd, requestedKind: "git" })
|
||||
.pipe(
|
||||
Effect.map(
|
||||
(repository) =>
|
||||
repository !== null &&
|
||||
NodePath.resolve(repository.repository.rootPath) === NodePath.resolve(cwd),
|
||||
),
|
||||
);
|
||||
const isGitRepository: CheckpointStore["Service"]["isGitRepository"] = Effect.fn(
|
||||
"CheckpointStore.isGitRepository",
|
||||
)(function* (cwd) {
|
||||
const repository = yield* vcsRegistry.detect({ cwd, requestedKind: "git" });
|
||||
return (
|
||||
repository !== null &&
|
||||
(yield* canonicalizeWorkspacePath(repository.repository.rootPath)) ===
|
||||
(yield* canonicalizeWorkspacePath(cwd))
|
||||
);
|
||||
});
|
||||
|
||||
const captureCheckpoint: CheckpointStore["Service"]["captureCheckpoint"] = Effect.fn(
|
||||
"captureCheckpoint",
|
||||
|
||||
Reference in new issue
Block a user