Syntropy.Receipts.Git (syntropy v0.3.0)

Copy Markdown

Git bindings for code-review receipt runs.

Resolves the base/head refs of a review to commit SHAs and computes the diff_sha — the lowercase hex SHA-256 of the raw bytes of git diff --no-color --unified=0 --find-renames <base>...<head>. The arguments match the Librarian evidence engine's diff invocation exactly, so evidence packets and receipts produced for the same change bind to the same diff_sha. The exact argv and git version are surfaced so envelopes can record how the digest was produced.

All failures normalize to {:error, %{code: String.t(), message: String.t()}} maps (plus context fields), mirroring the source-tool adapter's error style.

Summary

Functions

Computes the review diff digest between two resolved commits.

Validates that path exists and is a git work tree, returning the expanded path. A .git regular file (linked work trees) is accepted.

Resolves ref to a full commit SHA via git rev-parse --verify.

The git --version line of the binary used for the diff, or nil when it cannot be read.

Functions

diff_sha(repo, base_sha, head_sha)

@spec diff_sha(String.t(), String.t(), String.t()) :: {:ok, map()} | {:error, map()}

Computes the review diff digest between two resolved commits.

Returns the diff SHA-256, the byte size of the diff, and the exact argv used, so the envelope can carry an audit trail for the binding.

ensure_repo(path)

@spec ensure_repo(term()) :: {:ok, String.t()} | {:error, map()}

Validates that path exists and is a git work tree, returning the expanded path. A .git regular file (linked work trees) is accepted.

resolve_sha(repo, ref)

@spec resolve_sha(String.t(), String.t()) :: {:ok, String.t()} | {:error, map()}

Resolves ref to a full commit SHA via git rev-parse --verify.

version()

@spec version() :: String.t() | nil

The git --version line of the binary used for the diff, or nil when it cannot be read.