pr_01m47d15m3e54sn21z27rpy5n9/services/repos/src/git-store.ts

23 lines1,084 bytesCodeBlame
1import type { Commit, GitAccess, TreeEntry } from "@g1t/contracts";
2
3/**
4 * The storage that actually holds git repositories. The repos service
5 * depends on this port; Artifacts is one adapter for it.
6 *
7 * `key` is the store's own name for a repo.
8 */
9export interface GitStore {
10 create(key: string, options: { description?: string; defaultBranch: string }): Promise<void>;
11 /** A copy-on-write copy of `sourceKey`. */
12 fork(sourceKey: string, targetKey: string): Promise<void>;
13 /** A remote URL and short-lived credential for git itself. */
14 access(key: string, scope: "read" | "write"): Promise<GitAccess>;
15
16 /** Newest first along the first-parent chain; empty for an unknown ref. */
17 log(key: string, ref: string, limit: number): Promise<Commit[]>;
18 /** Null when the tree does not exist. */
19 readTree(key: string, treeHash: string): Promise<TreeEntry[] | null>;
20 readBlob(key: string, blobHash: string): Promise<Blob | null>;
21 /** Null when the ref or path does not resolve to a file. */
22 readFile(key: string, ref: string, path: string): Promise<Blob | null>;
23}