Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): turn diffs follow branch switches #36343

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/36343/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 69 additions and 0 deletions (loading 3).

x
0 of 6 viewed, 6 left
66 additions and 0 deletionsapps/server/src/checkpointing/CheckpointStore.test.tsModified
View file
@@ -546,6 +546,72 @@
}),
​
+ it.effect.each([{ committed: "before the turn" }, { committed: "during the turn" }])(
+ "starts a turn that switched branches from the branch it landed on (committed $committed)",
+ ({ committed }) =>
+ Effect.gen(function* () {
+ const tmp = yield* makeTmpDir();
+ yield* initRepoWithCommit(tmp);
+ const checkpointStore = yield* CheckpointStore.CheckpointStore;
+ const threadId = ThreadId.make("checkpoint-branch-switch");
+ const [first, second, third] = [0, 1, 2].map((turn) =>
+ checkpointRefForThreadTurn(threadId, turn),
+ ) as [CheckpointRef, CheckpointRef, CheckpointRef];
+ const changedSince = (fromCheckpointRef: CheckpointRef, toCheckpointRef: CheckpointRef) =>
+ Effect.gen(function* () {
+ const refs = { cwd: tmp, fromCheckpointRef, toCheckpointRef };
+ return {
+ patch: yield* checkpointStore.diffCheckpoints({ ...refs, ignoreWhitespace: false }),
+ authored: yield* checkpointStore.listAuthoredPaths(refs),
+ };
+ });
+ const commitOnA = git(tmp, ["commit", "-am", "work on a"]);
+​
+ yield* git(tmp, ["branch", "b"]);
+ yield* git(tmp, ["checkout", "-b", "a"]);
+ yield* writeTextFile(NodePath.join(tmp, "a.txt"), "a\n");
+ yield* writeTextFile(NodePath.join(tmp, "README.md"), "# on a\n");
+ yield* git(tmp, ["add", "."]);