Identitytypeno test imports ittype Identity = { readonly name: string; readonly email: string };Who a commit is by: the program that writes without a person.
A branch of a Git repository kept as a store of files (commons grc 0013-grc-gitref): for evidence that a program writes without a person, many times a day. A commit is made with Git's plumbing (hash-object, a temporary index, write-tree, commit-tree, update-ref guarded by the tip it was made on), so that the working tree, the index and the branch a person has checked out are never touched; only the files whose bytes differ from the tip are written, so that nothing that did not change is a commit; a file that is read, listed or followed through the history is read from the branch; the commits of an instant are those at or before it; and the branch, and only it, is pushed, never forced.
import { gitRefStore } from "./mod.ts";
// const store = gitRefStore({ repo: ".", branch: "evidence", identity: { name: "collector", email: "collector@localhost" } });
// await store.commit([{ path: "state/olympia.json", bytes }], "olympia: state changed");Identitytypeno test imports ittype Identity = { readonly name: string; readonly email: string };Who a commit is by: the program that writes without a person.
GitRefOptionstypeno test imports ittype GitRefOptions = { readonly repo: string; readonly branch: string; readonly identity: Identity };What a store is made over.
FileChangetypeno test imports ittype FileChange = { readonly path: string; readonly bytes: Uint8Array };A file to write: its path in the branch and its bytes.
Committedtypeno test imports ittype Committed = { readonly commit: string | undefined; readonly changed: readonly string[] };What a commit came to: the commit made (none where no file differed) and the paths that differed.
Revisiontypeno test imports ittype Revision = { readonly commit: string; readonly at: string; readonly subject: string };One commit that touched a path: the commit, its instant (ISO 8601, UTC) and its subject.
GitRefErrortypeno test imports ittype GitRefError = { readonly kind: "git" | "moved" | "path"; readonly message: string };Why a call of Git did not do what was asked.
GitRefStoretypetype GitRefStore = {
readonly repo: string;
readonly branch: string;
/** The tip of the branch, or nothing where t… (1169 characters)type GitRefStore = {
readonly repo: string;
readonly branch: string;
/** The tip of the branch, or nothing where the branch does not exist yet. */
head(): Promise<string | undefined>;
/** The bytes of a file at the tip (or at a commit), or nothing where there is none. */
read(file: string, at?: string): Promise<Uint8Array | undefined>;
/** The files under a folder at the tip (or at a commit), as paths of the branch, in order. */
list(folder: string, at?: string): Promise<readonly string[]>;
/** Writes the files that differ from the tip in one commit, made at `when` (now where none); a commit that would change nothing is not made. */
commit(changes: readonly FileChange[], message: string, when?: string): Promise<Result<Committed, GitRefError>>;
/** The commits that touched a path, newest first. */
history(file: string): Promise<readonly Revision[]>;
/** The newest commit made at or before an instant. */
at(instant: string): Promise<string | undefined>;
/** Pushes the branch, and nothing else, to a remote; never forced, so a remote that has moved is an error. */
push(remote: string): Promise<Result<void, GitRefError>>;
};The store.
gitRefStorefunctionfunction gitRefStore(o: GitRefOptions): GitRefStoreA store over a branch of a repository.