feat: reconcile generated docs on explicit registry pull
This commit is contained in:
@@ -178,6 +178,45 @@ export class GitWorkspaceRepository {
|
||||
return (await this.git(["rev-parse", `${revision}:${path}`])).trim();
|
||||
}
|
||||
|
||||
/** Read-only object type at an exact revision, or undefined when absent. */
|
||||
async gitObjectType(revision: string, path: string): Promise<string | undefined> {
|
||||
if (!/^[0-9a-f]{40}$/.test(revision)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace revision is invalid");
|
||||
}
|
||||
if (!/^[a-z][a-z0-9-]{2,62}\/workspace\.yaml$/.test(path)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace repository path is invalid");
|
||||
}
|
||||
return await this.gitOptional(["cat-file", "-t", `${revision}:${path}`]);
|
||||
}
|
||||
|
||||
/** Read a generated-doc blob at an exact revision, or undefined when absent. */
|
||||
async readObjectOrAbsent(revision: string, path: string): Promise<string | undefined> {
|
||||
if (!/^[0-9a-f]{40}$/.test(revision)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace revision is invalid");
|
||||
}
|
||||
if (!/^workspace-docs\/[a-z][a-z0-9-]{2,62}\/(?:contract\.env\.example|README\.md)$/.test(path)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace repository path is invalid");
|
||||
}
|
||||
const output = await this.gitOptional(["show", `${revision}:${path}`]);
|
||||
return output === undefined ? undefined : output;
|
||||
}
|
||||
|
||||
/** List committed generated-doc paths at an exact revision. */
|
||||
async workspaceDocsPaths(revision: string): Promise<string[]> {
|
||||
if (!/^[0-9a-f]{40}$/.test(revision)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace revision is invalid");
|
||||
}
|
||||
const output = await this.git(["ls-tree", "-r", "--name-only", revision, "--", "workspace-docs"]);
|
||||
if (output.trim() === "") return [];
|
||||
const paths = output.trim().split("\n");
|
||||
for (const path of paths) {
|
||||
if (!/^workspace-docs\/[a-z][a-z0-9-]{2,62}\/(?:contract\.env\.example|README\.md)$/.test(path)) {
|
||||
throw new WorkspaceRegistryError("workspace_invalid", "Workspace repository contains an invalid docs path");
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
/** Assert that a canonical Evidence root is a Git tree at an exact commit. */
|
||||
async assertTreeAtRevision(revision: string, repoRelativePath: string): Promise<void> {
|
||||
if (!/^[0-9a-f]{40}$/.test(revision)
|
||||
|
||||
Reference in New Issue
Block a user