Git commit helpers for single-repo and multi-repo prompt runs, plus the
read-only repository inspection used by the verifier and by watch.
Everything in the inspection surface uses git -C <root> rather than the
:cd option so a path that does not exist reports a git error instead of
raising, and nothing in it writes: not the working tree, not the index, not a
local branch, and not a remote-tracking ref.
Summary
Functions
Runs a git command in root and returns {output, exit_code}.
Returns the number of commits reachable from HEAD, or nil when unavailable.
Resolves ref on remote and returns its object id, under a bounded timeout.
Returns the trimmed git status --porcelain lines for root.
Returns the upstream ref for the current branch (for example origin/main),
or nil when the branch has no upstream configured.
Runs a git command in root and returns its trimmed output, or nil on failure.
Returns true when root is inside a git work tree.
Types
@type source() :: PromptRunner.Plan.t() | PromptRunner.Config.t()
Functions
@spec cmd(String.t(), [String.t()]) :: {String.t(), non_neg_integer()}
Runs a git command in root and returns {output, exit_code}.
@spec commit_count(String.t()) :: non_neg_integer() | nil
Returns the number of commits reachable from HEAD, or nil when unavailable.
@spec ls_remote(String.t(), String.t(), String.t(), timeout()) :: {:ok, String.t()} | {:error, term()}
Resolves ref on remote and returns its object id, under a bounded timeout.
git ls-remote is a pure query: it opens a connection, reads the remote's ref
advertisement, and writes nothing. Unlike git fetch it does not create or
move remote-tracking refs, so a verify clause built on it cannot alter the
repository it is judging — a gate that mutates anything in its subject is a
gate that can change the thing it measures.
The timeout matters because a verify clause runs after the model work is already spent: an unreachable remote must not hang the run.
Returns {:error, :ref_absent} when the remote has no such ref.
Returns the trimmed git status --porcelain lines for root.
An empty list means the working tree is clean.
Returns the upstream ref for the current branch (for example origin/main),
or nil when the branch has no upstream configured.
Runs a git command in root and returns its trimmed output, or nil on failure.
Returns true when root is inside a git work tree.