IF Commons GitHub

host/git

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-quality-evidence FR-021

Real git, run by its argument vector for the quality branch (commons 0001-quality-evidence FR-021, FR-023): never through a shell, with no pager, no terminal prompt and messages in English. The host's own Git configuration is what signs (gpg.format, user.signingkey, commit.gpgsign) and names the committer; nothing here holds a key. Every failure is a Result, a missing git included.

import { git, text } from "./git.ts";
const r = await git(".", ["rev-parse", "HEAD"]);
if (r.kind === "ok") console.log(text(r.value).trim());

Source: commons/quality/src/host/git.ts

1 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.

formatHostErrorfunctionno test imports it
function formatHostError(e: HostError): string

A host error as one sentence.

HostErrortypeno test imports it
type HostError = | { readonly kind: "git-missing" } | { readonly kind: "git"; readonly args: readonly string[]; read… (520 characters)
type HostError =
  | { readonly kind: "git-missing" }
  | { readonly kind: "git"; readonly args: readonly string[]; readonly code: number; readonly message: string }
  | { readonly kind: "exists"; readonly path: string }
  | { readonly kind: "moved"; readonly branch: string }
  | { readonly kind: "unknown-commit"; readonly commit: string }
  | { readonly kind: "unsigned"; readonly reason: string }
  | { readonly kind: "refused"; readonly reason: string }
  | { readonly kind: "unreadable"; readonly reason: string };

Why the quality branch could not be read or written.

GitInputtypeno test imports it
type GitInput = { readonly input?: string | Uint8Array; readonly env?: Readonly<Record<string, string>> };

What git is given besides its arguments: text for its standard input, and variables for its environment.

GitRantypeno test imports it
type GitRan = { readonly stdout: Uint8Array; readonly stderr: string; readonly code: number };

What a git run wrote, and how it ended.

gitRawfunctionno test imports it
function gitRaw(repo: string, args: readonly string[], options?: GitInput): Promise<Result<GitRan, HostError>>

git --no-pager -C repo ...args: what it wrote and its status; git-missing where there is no git. A non-zero status is not an error here.

gitfunction
function git(repo: string, args: readonly string[], options?: GitInput): Promise<Result<Uint8Array<ArrayBufferLike>, HostError>>

git run, where a status of 0 is a success: its output; the failure otherwise names what git said.

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

textfunctionno test imports it
function text(bytes: Uint8Array<ArrayBufferLike>): string

Bytes as UTF-8 text.

gitTextfunctionno test imports it
function gitText(repo: string, args: readonly string[], options?: GitInput): Promise<Result<string, HostError>>

git run for its text, trimmed.

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