Skip to content

Commit 0862494

Browse files
committed
fix(server): checkpoint restore keeps a nested workspace on Windows
- Recreate the workspace directory after git clean, which can remove './' and exit 0 on Windows - Assert the nested workspace still exists after each restore
1 parent cc1e634 commit 0862494

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ it.effect("restores empty checkpoints without changing paths outside the workspa
10851085
fallbackToHead: false,
10861086
}),
10871087
);
1088+
assert.isTrue(yield* fileSystem.exists(cwd));
10881089
assert.isFalse(yield* fileSystem.exists(addedPath));
10891090
}
10901091
yield* fileSystem.writeFileString(

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
10951095
});
10961096
}
10971097
// Restoring away the last tracked file can remove a nested workspace directory.
1098-
yield* fileSystem.makeDirectory(input.cwd, { recursive: true }).pipe(
1098+
const recreateWorkspace = fileSystem.makeDirectory(input.cwd, { recursive: true }).pipe(
10991099
Effect.mapError(
11001100
(cause) =>
11011101
new VcsProcessExitError({
@@ -1107,6 +1107,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
11071107
}),
11081108
),
11091109
);
1110+
yield* recreateWorkspace;
11101111
const cleaned = yield* execute({
11111112
operation,
11121113
cwd: input.cwd,
@@ -1131,6 +1132,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
11311132
detail: cleaned.stderr.trim() || "Could not clean the checkpoint workspace.",
11321133
});
11331134
}
1135+
// On Windows the same clean can remove './' and exit 0.
1136+
yield* recreateWorkspace;
11341137

11351138
const headExists = yield* hasHeadCommit(input.cwd);
11361139
if (headExists) {

0 commit comments

Comments
 (0)