feat: declare workspace repository in installation config

This commit is contained in:
2026-08-14 16:32:58 +02:00
parent 9db4463a83
commit 747020a330
9 changed files with 294 additions and 13 deletions
+27 -1
View File
@@ -4,7 +4,11 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { promisify } from "node:util";
import { afterEach, expect, test } from "vitest";
import { GitWorkspaceRepository, WorkspaceRepositoryLock } from "../src/workspaces/git-repository.js";
import {
GitWorkspaceRepository,
WorkspaceRepositoryLock,
normalizeRepositoryIdentity,
} from "../src/workspaces/git-repository.js";
import type { WorkspaceRegistryConfig } from "../src/workspaces/types.js";
const validYaml = `workspace:
@@ -102,6 +106,28 @@ test("does not expose repository mutation or publication operations", async () =
expect(repository).not.toHaveProperty("commitAndPush");
});
test.each([
["https://github.com/aritmolab/workspaces.git", {
host: "github.com", repository: "aritmolab/workspaces", transport: "https",
}],
["ssh://git@gitlab.example.org/clinical/workspaces.git", {
host: "gitlab.example.org", repository: "clinical/workspaces", transport: "ssh",
}],
["git@gitea.example.org:clinical/workspaces.git", {
host: "gitea.example.org", repository: "clinical/workspaces", transport: "ssh",
}],
] as const)("normalizes the safe repository identity for %s", (remote, expected) => {
expect(normalizeRepositoryIdentity(remote)).toEqual(expected);
});
test.each([
"https://user:secret@github.com/aritmolab/workspaces.git",
"https://github.com/aritmolab/workspaces.git?token=secret",
"ssh://git:secret@gitlab.example.org/clinical/workspaces.git",
])("rejects a remote that could expose embedded credentials: %s", (remote) => {
expect(() => normalizeRepositoryIdentity(remote)).toThrow("Workspace Git remote is invalid");
});
test("bootstraps a persistent checkout from a local bare repository", async () => {
const fixture = await temporaryRemote();
const repository = new GitWorkspaceRepository(config(join(fixture.root, "registry"), fixture.remote));