IF Commons GitHub

changes/git-log

The host layer of the changes check that reads Git (commons 0020-ifccm FR-005, FR-007, FR-012): the commits of a range with their parents, authors, days and messages, and the history of a declaration file, each read by running the real git by its argument vector (never through a shell), with no pager and no terminal prompt. Every failure is an Err naming what went wrong; nothing here throws.

The range is any range git log takes (A..B, a single revision for its whole history). Commits come oldest first. A declaration's history is every commit that changed its file, oldest first, each version read from Git as text and decoded without being run (declaration.ts); a version that does not decode is left out, since the rule judges declarations and not typing.

import { readRange } from "./git-log.ts";
const r = await readRange(".", "origin/main..HEAD");
if (r.kind === "ok") console.log(r.value.length);

Source: commons/mizan/src/changes/git-log.ts

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

changes.declarationHistoryfunctionno test imports it
function declarationHistory(repo: string, file: string, rev?: string): Promise<Result<readonly DeclarationVersion[], GitError>>

The versions of a declaration file in the history of rev (HEAD by default), oldest first: the revision that wrote each, the day of that commit and the declaration then. A commit that removed the file gives a version with no declaration; one whose text does not decode is left out.

changes.readRangefunctionno test imports it
function readRange(repo: string, range: string): Promise<Result<readonly CommitFacts[], GitError>>

The commits of a range, oldest first: each with its parents, its author, the day it was committed and its whole message. A range that starts with - is refused, not passed to git.

changes.readRangeFactsfunctionno test imports it
function readRangeFacts(repo: string, range: string): Promise<Result<readonly CapabilityCommit[], GitError>>

The commits of a range as the offline trace reads them (0020-ifccm FR-035): each with its subject, its whole message, the files it changed and the requirements (NNNN-slug FR-nnn) whose lines in a specs/<slug>/spec.md it added or edited. Three reads of the one range, each by an argument vector.

declarationHistoryfunction
function declarationHistory(repo: string, file: string, rev?: string): Promise<Result<readonly DeclarationVersion[], GitError>>

The versions of a declaration file in the history of rev (HEAD by default), oldest first: the revision that wrote each, the day of that commit and the declaration then. A commit that removed the file gives a version with no declaration; one whose text does not decode is left out.

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

readRangefunction
function readRange(repo: string, range: string): Promise<Result<readonly CommitFacts[], GitError>>

The commits of a range, oldest first: each with its parents, its author, the day it was committed and its whole message. A range that starts with - is refused, not passed to git.

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

readRangeFactsfunctionno test imports it
function readRangeFacts(repo: string, range: string): Promise<Result<readonly CapabilityCommit[], GitError>>

The commits of a range as the offline trace reads them (0020-ifccm FR-035): each with its subject, its whole message, the files it changed and the requirements (NNNN-slug FR-nnn) whose lines in a specs/<slug>/spec.md it added or edited. Three reads of the one range, each by an argument vector.

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