Skip to content

Commit a119af0

Browse files
fix(server): remote status keeps a local upstream named without a slash (#35766)
1 parent 59e64ee commit a119af0

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,6 +3873,25 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
38733873
}),
38743874
);
38753875

3876+
it.effect("reports a local upstream without a slash and its divergence", () =>
3877+
Effect.gen(function* () {
3878+
const cwd = yield* makeTmpDir();
3879+
yield* initRepoWithCommit(cwd);
3880+
const initialBranch = yield* git(cwd, ["symbolic-ref", "--short", "HEAD"]);
3881+
yield* git(cwd, ["branch", "feature"]);
3882+
yield* git(cwd, ["commit", "--allow-empty", "-m", "advance base"]);
3883+
yield* git(cwd, ["checkout", "feature"]);
3884+
yield* git(cwd, ["branch", `--set-upstream-to=${initialBranch}`]);
3885+
const driver = yield* GitVcsDriver.GitVcsDriver;
3886+
3887+
const remoteStatus = yield* driver.statusDetailsRemote(cwd, { refreshUpstream: false });
3888+
assert.equal(remoteStatus.upstreamRef, initialBranch);
3889+
assert.equal(remoteStatus.hasUpstream, true);
3890+
assert.equal(remoteStatus.aheadCount, 0);
3891+
assert.equal(remoteStatus.behindCount, 1);
3892+
}),
3893+
);
3894+
38763895
it.effect("does not open a project folder laid out as a bare repository", () =>
38773896
Effect.gen(function* () {
38783897
const cwd = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,10 +2098,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
20982098
branch = branchNameFromHeadRef(branchResult.stdout);
20992099
}
21002100
const currentUpstreamRef = yield* readCurrentUpstreamRef(cwd);
2101-
let upstreamRef =
2102-
currentUpstreamRef === null
2103-
? null
2104-
: (parseUpstreamRefByFirstSeparator(currentUpstreamRef)?.upstreamRef ?? null);
2101+
let upstreamRef = currentUpstreamRef;
21052102
// Trimming a remote that starts with Unicode whitespace can leave a leading slash.
21062103
if (currentUpstreamRef?.startsWith("/")) {
21072104
upstreamRef = (yield* resolveCurrentUpstream(cwd, currentUpstreamRef))?.upstreamRef ?? null;

0 commit comments

Comments
 (0)