Skip to content

Commit 37df38f

Browse files
committed
fix(server): a failed switch names a missing ref on hosts with translated git output
1 parent 25226f1 commit 37df38f

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,18 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
28812881
}),
28822882
);
28832883

2884+
it.effect("names the missing ref behind a failed switch", () =>
2885+
Effect.gen(function* () {
2886+
const cwd = yield* makeTmpDir();
2887+
yield* initRepoWithCommit(cwd);
2888+
const driver = yield* GitVcsDriver.GitVcsDriver;
2889+
2890+
const error = yield* driver.switchRef({ cwd, refName: "deleted-branch" }).pipe(Effect.flip);
2891+
2892+
assert.deepInclude(error, { detail: "git checkout failed", reason: "ref_not_found" });
2893+
}),
2894+
);
2895+
28842896
it.effect("still creates and reuses remote tracking branches and allows detached refs", () =>
28852897
Effect.gen(function* () {
28862898
const cwd = yield* makeTmpDir();

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3967,10 +3967,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
39673967
: ["checkout", input.refName];
39683968

39693969
// A stale ref must not turn into a path checkout that discards local edits.
3970-
yield* executeGit("GitVcsDriver.switchRef.checkout", input.cwd, [...checkoutArgs, "--"], {
3971-
timeoutMs: 10_000,
3972-
fallbackErrorDetail: "git checkout failed",
3973-
});
3970+
yield* executeGitWithStableDiagnostics(
3971+
"GitVcsDriver.switchRef.checkout",
3972+
input.cwd,
3973+
[...checkoutArgs, "--"],
3974+
{
3975+
timeoutMs: 10_000,
3976+
fallbackErrorDetail: "git checkout failed",
3977+
},
3978+
);
39743979

39753980
const refName = yield* runGitStdout("GitVcsDriver.switchRef.currentBranch", input.cwd, [
39763981
"branch",

0 commit comments

Comments
 (0)