TypeScript
fix(server): checkpoint restore keeps a nested workspace on Windows (#14874)
Jonas B.a5331e4c2c0f
diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.tsindex a6bbef6ed1d..3a7a16f95d4 100644--- a/apps/server/src/vcs/GitVcsDriver.test.ts+++ b/apps/server/src/vcs/GitVcsDriver.test.ts@@ -1049,6 +1049,7 @@ it.effect("restores empty checkpoints without changing paths outside the workspafallbackToHead: false,}),);+ assert.isTrue(yield* fileSystem.exists(cwd));assert.isFalse(yield* fileSystem.exists(addedPath));}yield* fileSystem.writeFileString(diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.tsindex 599269791ed..3803c78fc6d 100644--- a/apps/server/src/vcs/GitVcsDriver.ts+++ b/apps/server/src/vcs/GitVcsDriver.ts@@ -1114,7 +1114,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (});}// Restoring away the last tracked file can remove a nested workspace directory.- yield* fileSystem.makeDirectory(input.cwd, { recursive: true }).pipe(+ const recreateWorkspace = fileSystem.makeDirectory(input.cwd, { recursive: true }).pipe(Effect.mapError((cause) =>new VcsProcessExitError({@@ -1126,6 +1126,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (}),),);+ yield* recreateWorkspace;const cleaned = yield* execute({operation,cwd: input.cwd,@@ -1150,6 +1151,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (detail: cleaned.stderr.trim() || "Could not clean the checkpoint workspace.",});}+ // On Windows the same clean can remove './' and exit 0.+ yield* recreateWorkspace;const headExists = yield* hasHeadCommit(input.cwd);if (headExists) {