diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.ts index fba2a96d5f7f3..677ebb59ae0a7 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.test.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts @@ -3873,6 +3873,25 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => { }), ); + it.effect("reports a local upstream without a slash and its divergence", () => + Effect.gen(function* () { + const cwd = yield* makeTmpDir(); + yield* initRepoWithCommit(cwd); + const initialBranch = yield* git(cwd, ["symbolic-ref", "--short", "HEAD"]); + yield* git(cwd, ["branch", "feature"]); + yield* git(cwd, ["commit", "--allow-empty", "-m", "advance base"]); + yield* git(cwd, ["checkout", "feature"]); + yield* git(cwd, ["branch", `--set-upstream-to=${initialBranch}`]); + const driver = yield* GitVcsDriver.GitVcsDriver; + + const remoteStatus = yield* driver.statusDetailsRemote(cwd, { refreshUpstream: false }); + assert.equal(remoteStatus.upstreamRef, initialBranch); + assert.equal(remoteStatus.hasUpstream, true); + assert.equal(remoteStatus.aheadCount, 0); + assert.equal(remoteStatus.behindCount, 1); + }), + ); + it.effect("does not open a project folder laid out as a bare repository", () => Effect.gen(function* () { const cwd = yield* makeTmpDir(); diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts index ee1f7bb9cdd06..e183c4958993e 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.ts @@ -2098,10 +2098,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* branch = branchNameFromHeadRef(branchResult.stdout); } const currentUpstreamRef = yield* readCurrentUpstreamRef(cwd); - let upstreamRef = - currentUpstreamRef === null - ? null - : (parseUpstreamRefByFirstSeparator(currentUpstreamRef)?.upstreamRef ?? null); + let upstreamRef = currentUpstreamRef; // Trimming a remote that starts with Unicode whitespace can leave a leading slash. if (currentUpstreamRef?.startsWith("/")) { upstreamRef = (yield* resolveCurrentUpstream(cwd, currentUpstreamRef))?.upstreamRef ?? null;