IF Commons GitHub

stores/gitref/mod

Written to: 6 requirements: 6 proved, 0 partly, 0 failing, 0 with no test recorded. 0013-grc-gitref FR-001, 0013-grc-gitref FR-002, 0013-grc-gitref FR-003, 0013-grc-gitref FR-004, 0013-grc-gitref FR-005, 0013-grc-gitref FR-006

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");

Source: commons/grc/src/stores/gitref/mod.ts

2 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Identitytypeno test imports it
type Identity = { readonly name: string; readonly email: string };

Who a commit is by: the program that writes without a person.

GitRefOptionstypeno test imports it
type GitRefOptions = { readonly repo: string; readonly branch: string; readonly identity: Identity };

What a store is made over.

FileChangetypeno test imports it
type FileChange = { readonly path: string; readonly bytes: Uint8Array };

A file to write: its path in the branch and its bytes.

Committedtypeno test imports it
type 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 it
type 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 it
type GitRefError = { readonly kind: "git" | "moved" | "path"; readonly message: string };

Why a call of Git did not do what was asked.

GitRefStoretype
type 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.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

gitRefStorefunction
function gitRefStore(o: GitRefOptions): GitRefStore

A store over a branch of a repository.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.