Documentation
¶
Overview ¶
Package gitfacts reads the few facts about a checkout the manager digest's state entry carries (card 162, manager-digest plan §5.3): the commit HEAD names and the branch it is on, read from git's own files with no process started; the commits a session made since it started, which only git itself can list, so `git log` is run — an argument array, the allow-listed child environment, never a shell, a short deadline, and nothing but its stdout read; and whether a path is ignored, which `git check-ignore` answers. Every failure leaves the caller's facts as they were: a checkout without git, a repository with no commit yet and a `.git` nobody can read all answer "nothing known", never an error a hook would print.
Index ¶
Constants ¶
const ( // MaxLogCommits caps one `git log`: a session that made more commits // since it started keeps the newest ones, which the digest's own cap // (40 lines) never exceeds anyway. MaxLogCommits = 100 // MaxSubjectChars caps a commit subject the entry carries, in code // points, with protocol.TruncationMarker when cut. MaxSubjectChars = 200 )
The bounds of what one git call may hand back.
Variables ¶
var ErrNoGit = errors.New("gitfacts: no git on PATH")
ErrNoGit is the error of a Runner whose environment's PATH has no git.
Functions ¶
func Head ¶
Head reads what HEAD names in the checkout at top, from git's own files: the commit hash, and the branch when HEAD is symbolic ("" when detached). A repository whose HEAD names a branch with no commit yet answers the branch and no hash; anything unreadable answers nothing at all. No process is started: this runs at every prompt.
Types ¶
type Commit ¶
A Commit is one commit `git log` listed: the full hash, the subject (sanitised and capped), the card number the subject starts with (the repository's `<card>: <summary>` convention, 0 when it starts with none) and the commit time.
type Runner ¶
A Runner runs git in one checkout: the toplevel, the environment the child's allow-listed one is built from (the hook's or the command's own, in os.Environ form) and the deadline each call gets. Git is found on that environment's PATH, never on this process's.
func (Runner) AuthorEmail ¶
AuthorEmail is `user.email` as git resolves it for the checkout: the value the commits a session makes there carry, so Log can keep to them. "" when none is configured.
func (Runner) Ignored ¶
Ignored reports whether git ignores path in the checkout — the answer `git check-ignore` gives (exit 0 ignored, 1 not), with the path given after `--` so it is never read as an option.
func (Runner) Log ¶
Log lists the commits reachable from HEAD and not from since (the `since..HEAD` range), newest first as git lists them, at most MaxLogCommits; with author set, only those whose author line contains it, matched as fixed text. An empty since lists nothing: the entry's start head is what makes a range, and a session with none made no commit Brigade could attribute.