The best way to control Claude Code, Codex and more from any computer or phone
fix(server): Changes base follows the remote a plain recorded base branch tracks (#38543)
Julius Marminge committed
Nov 18, 2026 at 02:31 UTC
3babab1497ddd82dfd90a0d53ad4d16ebae41063
2 files changed
+44
apps/server/src/vcs/GitVcsDriverCore.test.ts
+40
@@ -4420,6 +4420,46 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4420
}),
4421
);
4422
4423
+ it.effect("compares a plain recorded base with the remote that base branch tracks", () =>
4424
+ Effect.gen(function* () {
4425
+ const cwd = yield* makeTmpDir();
4426
+ const fork = yield* makeTmpDir();
4427
+ const upstream = yield* makeTmpDir();
4428
+ yield* initRepoWithCommit(cwd);
4429
+ const driver = yield* GitVcsDriver.GitVcsDriver;
4430
+ yield* git(cwd, ["branch", "-M", "main"]);
4431
+ yield* git(fork, ["init", "--bare"]);
4432
+ yield* git(upstream, ["init", "--bare"]);
4433
+ yield* git(cwd, ["remote", "add", "origin", fork]);
4434
+ yield* git(cwd, ["remote", "add", "upstream", upstream]);
4435
+ yield* git(cwd, ["push", "origin", "main"]);
4436
+ yield* writeTextFile(cwd, "upstream.txt", "unrelated upstream work\n");
4437
+ yield* git(cwd, ["add", "upstream.txt"]);
4438
+ yield* git(cwd, ["commit", "-m", "upstream work"]);
4439
+ yield* git(cwd, ["push", "-u", "upstream", "main"]);
4440
+ yield* git(cwd, ["checkout", "-b", "feature/from-local-main"]);
4441
+ yield* git(cwd, ["config", "branch.feature/from-local-main.t3-merge-base", "main"]);
4442
+ yield* writeTextFile(cwd, "feature.txt", "intended branch change\n");
4443
+ yield* git(cwd, ["add", "feature.txt"]);
4444
+ yield* git(cwd, ["commit", "-m", "feature work"]);
4445
+
4446
+ const status = yield* driver.statusDetailsLocal(cwd, { includeBranchChanges: true });
4447
+ assert.deepStrictEqual(status.branchChanges, {
4448
+ baseRef: "upstream/main",
4449
+ insertions: 1,
4450
+ deletions: 0,
4451
+ });
4452
+ assert.strictEqual(status.aheadCount, 1);
4453
+ const preview = yield* driver.getReviewDiffPreview({ cwd });
4454
+ const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4455
+ assert.strictEqual(changes.baseRef, "upstream/main");
4456
+ assert.deepStrictEqual(
4457
+ changes.files?.map((file) => file.path),
4458
+ ["feature.txt"],
4459
+ );
4460
+ }),
4461
+ );
4462
+
4463
it.effect("does not guess a Changes base for a branch renamed during the status read", () =>
4464
Effect.gen(function* () {
4465
const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+4
@@ -2158,6 +2158,10 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2158
return { baseRef: comparisonRef, comparisonRef };
2159
}
2160
if (configuredBase !== null) return configuredBase;
2161
+ if (configuredBaseBranch.length > 0 && configuredBaseBranch !== refName) {
2162
+ const trackedBase = yield* resolveTrackedRemoteBaseRef(cwd, configuredBaseBranch);
2163
+ if (trackedBase !== null) return trackedBase;
2164
+ }
2165
2166
const primaryRemoteName = yield* resolvePrimaryRemoteName(cwd).pipe(
2167
Effect.orElseSucceed(() => null),