дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Fixes from a second review of the built-in Subversion support: rollback keeps moved and needs-lock files intact, a failed commit staging step undoes only the schedules it made, mixed Git/SVN Commit All no longer pulls in unstaged Git edits, status refreshes keep failed roots' rows without resurrecting cleaned ones, BASE image sizes follow copy history, logins say whether the user asked, Windows passwords are sent in the console code page, and background Log refreshes share one SVN branch lookup so a cancelled login is not re-prompted. Co-authored-by: wildcatDownstairs <[email protected]>
104 рядки
4.2 KiB
TypeScript
104 рядки
4.2 KiB
TypeScript
/**
|
|
* A Subversion working copy through `openidea-server`: the shared `vcs_*` commands find it,
|
|
* list its changes, commit them and read its log, called directly (the Commit window's own
|
|
* path is in src/features/vcs/__tests__/svnCommitWindow.test.ts). Skipped when `svn` or
|
|
* `svnadmin` is not installed. The server runs svn non-interactively. No CI workflow runs the
|
|
* smoke tests: run it by hand (`pnpm smoke smoke/svn.test.ts`). CI's Rust job runs the same checks
|
|
* through the server protocol:
|
|
* crates/ide-host/tests/svn.rs `a_working_copy_through_the_server_protocol`.
|
|
*/
|
|
import { execFileSync } from "node:child_process";
|
|
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
import { afterEach, expect, test } from "vitest";
|
|
import { commands } from "@/bindings";
|
|
import { openProject, useProject } from "@/platform/project";
|
|
import { connectDesktop } from "./desktop";
|
|
import { Server } from "./server";
|
|
|
|
function installed(tool: string): boolean {
|
|
try {
|
|
execFileSync(tool, ["--version", "--quiet"], { stdio: "ignore" });
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
const svn = installed("svn") && installed("svnadmin");
|
|
// Skipped where svn is not installed, but never silently in CI.
|
|
const ci = !!process.env.CI && process.env.CI !== "false";
|
|
if (ci && !svn) throw new Error("CI must install svn and svnadmin for the Subversion smoke test");
|
|
let base = "";
|
|
let server: Server | null = null;
|
|
let disconnect: (() => void) | null = null;
|
|
|
|
afterEach(async () => {
|
|
disconnect?.();
|
|
disconnect = null;
|
|
await server?.close();
|
|
server = null;
|
|
if (base) rmSync(base, { recursive: true, force: true });
|
|
base = "";
|
|
});
|
|
|
|
function ok<T>(result: { status: "ok"; data: T } | { status: "error"; error: { message: string } }): T {
|
|
if (result.status !== "ok") throw new Error(result.error.message);
|
|
return result.data;
|
|
}
|
|
|
|
test.skipIf(!svn)("commits and logs a Subversion working copy through the server", { timeout: 120_000 }, async () => {
|
|
base = realpathSync(mkdtempSync(join(tmpdir(), "openidea-smoke-svn-")));
|
|
const config = join(base, "svn-config");
|
|
const run = (args: string[], cwd = base) =>
|
|
execFileSync("svn", [...args, "--non-interactive", "--config-dir", config], {
|
|
cwd,
|
|
env: { ...process.env, LC_MESSAGES: "C" },
|
|
});
|
|
execFileSync("svnadmin", ["create", join(base, "repo")]);
|
|
const url = pathToFileURL(join(base, "repo")).href;
|
|
run(["mkdir", "-q", "-m", "layout", `${url}/trunk`, `${url}/branches`]);
|
|
const root = join(base, "wc");
|
|
run(["checkout", "-q", `${url}/trunk`, root]);
|
|
|
|
// The server's svn reads the test's configuration, never ~/.subversion.
|
|
mkdirSync(join(base, "home", "config"), { recursive: true });
|
|
writeFileSync(
|
|
join(base, "home", "config", "settings.toml"),
|
|
`[vcs.svn]\nuseCustomConfigDir = true\nconfigDir = ${JSON.stringify(config)}\n`,
|
|
);
|
|
server = await Server.start(join(base, "home"));
|
|
disconnect = connectDesktop(server);
|
|
await openProject(root);
|
|
ok(await commands.projectTrustSet(root, true, false));
|
|
useProject.setState({ project: { ...useProject.getState().project!, trusted: true } });
|
|
|
|
// Working copies are looked for once the project is trusted.
|
|
await expect
|
|
.poll(async () => ok(await commands.vcsRoots()).map((r) => r.kind), { timeout: 30_000 })
|
|
.toEqual(["subversion"]);
|
|
expect(ok(await commands.vcsBranchInfo(null)).head).toBe("trunk");
|
|
|
|
writeFileSync(join(root, "notes.txt"), "first\n");
|
|
const status = ok(await commands.vcsStatus());
|
|
expect(status.map((f) => [f.relPath, f.unstaged])).toEqual([["notes.txt", "untracked"]]);
|
|
const revision = ok(
|
|
await commands.vcsCommit(null, "Add notes", {
|
|
amend: false,
|
|
signOff: false,
|
|
author: null,
|
|
runHooks: true,
|
|
stage: [join(root, "notes.txt")],
|
|
}),
|
|
);
|
|
expect(revision).toBe("2");
|
|
expect(ok(await commands.vcsStatus())).toEqual([]);
|
|
const log = ok(
|
|
await commands.vcsLog(null, { branch: null, path: null, author: null, text: null, skip: 0, limit: 10 }),
|
|
);
|
|
expect(log.map((c) => c.summary)).toEqual(["Add notes", "layout"]);
|
|
expect(run(["log", "-q", "-r", "2", url]).toString()).toContain("r2");
|
|
});
|