@devries-cameron20 / t3code-1 / commits / 064cf8f7ac
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): an upstream shadowed by a local origin/<branch> branch keeps its real remote (#29180)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 01:35 UTC 064cf8f7ac01aead41b3a6198b7c08a3a66e041a
2 files changed +13 -4
apps/server/src/vcs/GitVcsDriverCore.test.ts
+9 -1
@@ -3169,16 +3169,24 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3169 });
3170
3171 describe("repository status", () => {
3172 - it.effect("reads the current branch by name when a tag shares it", () =>
3172 + it.effect("reads the current branch and upstream by name when other refs share them", () =>
3173 Effect.gen(function* () {
3174 const cwd = yield* makeTmpDir();
3175 + const remote = yield* makeTmpDir("git-vcs-driver-remote-");
3176 yield* initRepoWithCommit(cwd);
3177 + yield* git(remote, ["init", "--bare"]);
3178 + yield* git(cwd, ["remote", "add", "origin", remote]);
3179 yield* git(cwd, ["checkout", "-b", "release"]);
3180 + yield* git(cwd, ["push", "-u", "origin", "release"]);
3181 + yield* git(cwd, ["commit", "--allow-empty", "-m", "unpushed"]);
3182 + yield* git(cwd, ["branch", "origin/release"]);
3183 yield* git(cwd, ["tag", "release"]);
3184 const driver = yield* GitVcsDriver.GitVcsDriver;
3185
3186 const remoteStatus = yield* driver.statusDetailsRemote(cwd, { refreshUpstream: false });
3187 assert.equal(remoteStatus.branch, "release");
3188 + assert.equal(remoteStatus.upstreamRef, "origin/release");
3189 + assert.equal(remoteStatus.aheadCount, 1);
3190 const preview = yield* driver.getReviewDiffPreview({ cwd });
3191 const branchRange = preview.sources.find((source) => source.kind === "branch-range");
3192 assert.equal(branchRange?.headRef, "release");
apps/server/src/vcs/GitVcsDriverCore.ts
+4 -3
@@ -1293,13 +1293,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1293 });
1294 });
1295
1296 + // `--abbrev-ref` prints `remotes/origin/<name>` when a local `origin/<name>` branch exists.
1297 const readCurrentUpstreamRef = Effect.fn("readCurrentUpstreamRef")(function* (cwd: string) {
1298 const upstreamRef = yield* runGitStdout(
1299 "GitVcsDriver.resolveCurrentUpstream",
1300 cwd,
1300 - ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"],
1301 + ["rev-parse", "--symbolic-full-name", "@{upstream}"],
1302 true,
1302 - ).pipe(Effect.map((stdout) => stdout.trim()));
1303 + ).pipe(Effect.map((stdout) => stdout.trim().replace(/^refs\/(?:remotes|heads)\//, "")));
1304
1305 if (upstreamRef.length === 0 || upstreamRef === "@{upstream}") {
1306 return null;
@@ -2032,7 +2033,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2033 const divergence = yield* executeGit(
2034 "GitVcsDriver.statusDetailsRemote.divergence",
2035 cwd,
2035 - ["rev-list", "--left-right", "--count", `HEAD...${upstreamRef}`],
2036 + ["rev-list", "--left-right", "--count", "HEAD...@{upstream}"],
2037 { allowNonZeroExit: true },
2038 );
2039 if (divergence.exitCode === 0) {