mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(migrate): normalize source references
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
} from "@playwright/test";
|
||||
|
||||
test.skip(process.env.E2E_DESKTOP_RUNTIME !== "1", "requires the real Electron product runtime");
|
||||
test.setTimeout(180_000);
|
||||
|
||||
const repoRoot = path.resolve(__dirname, "../../..");
|
||||
let installation: Awaited<ReturnType<typeof createConductorInstallation>>;
|
||||
@@ -82,7 +83,7 @@ async function launchProduct(): Promise<ElectronApplication> {
|
||||
|
||||
async function openIntegrations(page: Page): Promise<void> {
|
||||
const settings = page.getByRole("button", { name: "Settings", exact: true });
|
||||
await expect(settings).toBeVisible({ timeout: 30_000 });
|
||||
await expect(settings).toBeVisible({ timeout: 90_000 });
|
||||
await settings.click();
|
||||
await expect(page.getByTestId("settings-sidebar")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Integrations", exact: true }).click();
|
||||
|
||||
@@ -110,6 +110,21 @@ test("reports malformed database JSON and script columns per project", async ()
|
||||
]);
|
||||
});
|
||||
|
||||
test("normalizes fully qualified local workspace branches", async () => {
|
||||
const databasePath = temporaryDatabase();
|
||||
cpSync(fixturePath, databasePath);
|
||||
const database = await openFixtureDatabase(databasePath);
|
||||
database.run("UPDATE workspaces SET branch = 'refs/heads/feature' WHERE branch IS NOT NULL");
|
||||
saveFixtureDatabase(databasePath, database);
|
||||
|
||||
const branches = (await readConductorCatalog(databasePath)).workspaces
|
||||
.map((workspace) => workspace.branch)
|
||||
.filter((branch): branch is string => branch !== null);
|
||||
|
||||
expect(branches).toContain("feature");
|
||||
expect(branches.some((branch) => branch.startsWith("refs/heads/"))).toBe(false);
|
||||
});
|
||||
|
||||
function temporaryDatabase(): string {
|
||||
const directory = mkdtempSync(path.join(os.tmpdir(), "paseo-migrate-db-"));
|
||||
cleanup.push(directory);
|
||||
|
||||
@@ -141,10 +141,11 @@ function parseRepo(value: unknown): ConductorRepoRecord {
|
||||
|
||||
function parseWorkspace(value: unknown): ConductorWorkspaceRecord {
|
||||
const row = record(value);
|
||||
const branch = optionalString(row.branch);
|
||||
return {
|
||||
id: stringColumn(row, "id"),
|
||||
repoId: stringColumn(row, "repo_id"),
|
||||
branch: optionalString(row.branch),
|
||||
branch: branch?.replace(/^refs\/heads\//, "") ?? null,
|
||||
state: stringColumn(row, "state"),
|
||||
path: optionalString(row.path),
|
||||
archiveCommit: optionalString(row.archive_commit),
|
||||
|
||||
@@ -76,6 +76,9 @@ cwd = "../outside"
|
||||
|
||||
[scripts.run.unknown_variable]
|
||||
command = "echo $CONDUCTOR_UNSUPPORTED_VALUE"
|
||||
|
||||
[scripts.run.unsupported_substitution]
|
||||
command = "serve --port \${CONDUCTOR_PORT/3000/3001}"
|
||||
`,
|
||||
);
|
||||
|
||||
@@ -93,6 +96,7 @@ command = "echo $CONDUCTOR_UNSUPPORTED_VALUE"
|
||||
"scripts.absolute.cwd: Absolute or escaping cwd values are not imported.",
|
||||
"scripts.escape.cwd: Absolute or escaping cwd values are not imported.",
|
||||
"scripts.unknown_variable: Unsupported Conductor variables: CONDUCTOR_UNSUPPORTED_VALUE. Command was not imported.",
|
||||
"scripts.unsupported_substitution: Unsupported Conductor variables: CONDUCTOR_PORT. Command was not imported.",
|
||||
"settings.unknown_project_setting: Unknown Conductor setting.",
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -602,7 +602,7 @@ function collectConductorVariables(command: string): string[] {
|
||||
const names = new Set<string>();
|
||||
const mask = activeShellMask(command);
|
||||
const direct =
|
||||
/\$\{(CONDUCTOR_[A-Za-z0-9_]+)(?=[}:#%+\-=?])|\$(CONDUCTOR_[A-Za-z0-9_]+)(?![A-Za-z0-9_])/g;
|
||||
/\$\{(CONDUCTOR_[A-Za-z0-9_]+)(?=[^A-Za-z0-9_])|\$(CONDUCTOR_[A-Za-z0-9_]+)(?![A-Za-z0-9_])/g;
|
||||
for (const match of command.matchAll(direct)) {
|
||||
if (mask[match.index] !== "$") continue;
|
||||
const name = match[1] ?? match[2];
|
||||
|
||||
Reference in New Issue
Block a user