Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,55 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("explains a non-fast-forward push from a host with a translated Git", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
const { initialBranch } = yield* initRepoWithCommit(cwd);
const remote = yield* makeTmpDir("git-remote-");
const other = yield* makeTmpDir("git-other-");
yield* git(remote, ["init", "--bare"]);
yield* git(cwd, ["remote", "add", "origin", remote]);
yield* git(cwd, ["push", "--set-upstream", "origin", initialBranch]);
yield* git(other, ["clone", "--branch", initialBranch, remote, "."]);
yield* git(other, [
"-c",
"user.email=t@t",
"-c",
"user.name=T",
"commit",
"--allow-empty",
"-m",
"remote",
]);
yield* git(other, ["push", "origin", initialBranch]);
yield* git(cwd, ["commit", "--allow-empty", "-m", "local"]);
const locales: Array<CommandLine.Word | undefined> = [];
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
const spawner = ChildProcessSpawner.make((command) => {
if (ChildProcess.isStandardCommand(command) && command.args.includes("push")) {
locales.push(command.options.env?.LANGUAGE);
}
return delegate.spawn(command);
});
const driver = yield* makeGitVcsDriverCore().pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.provide(layerServerConfig),
);
const hostEnv = yield* HostProcess.Environment;

const error = yield* driver
.pushCurrentBranch(cwd, null)
.pipe(
Effect.provideService(HostProcess.Environment, { ...hostEnv, LANGUAGE: "de" }),
Effect.flip,
);

assert.equal(error.reason, "push_rejected_non_fast_forward");
assert.isNotEmpty(locales);
for (const locale of locales) assert.equal(locale, "C");
}),
);

it.effect("lets a slow remote branch checkout finish without blocking config writes", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
Expand Down
10 changes: 6 additions & 4 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2912,7 +2912,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const requestedRemoteName = options?.remoteName?.trim() || null;
if (requestedRemoteName) {
const publishBranch = yield* resolvePublishBranchName(cwd, branch);
yield* runGit(
yield* executeGitWithStableDiagnostics(
"GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote",
cwd,
["push", "--", requestedRemoteName, `HEAD:refs/heads/${publishBranch}`],
Expand Down Expand Up @@ -3006,7 +3006,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
});
}
}
yield* runGit(
yield* executeGitWithStableDiagnostics(
upstream
? "GitVcsDriver.pushCurrentBranch.pushOwnBranch"
: "GitVcsDriver.pushCurrentBranch.pushWithUpstream",
Expand All @@ -3023,7 +3023,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
}

if (destination?.upstream) {
yield* runGit(
yield* executeGitWithStableDiagnostics(
"GitVcsDriver.pushCurrentBranch.pushUpstream",
cwd,
["push", "--", destination.remoteName, `HEAD:refs/heads/${destination.branchName}`],
Expand All @@ -3037,7 +3037,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
};
}

yield* runGit("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"], { timeoutMs: null });
yield* executeGitWithStableDiagnostics("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"], {
timeoutMs: null,
});
return {
status: "pushed" as const,
branch,
Expand Down
Loading