Exgit.Object.Commit (exgit v0.1.0)

Copy Markdown View Source

A git commit object.

Commits are represented as a message plus an ordered list of headers. Preserving both the order and the verbatim content of headers is required for SHA stability: two commits with the same logical content but different header orderings are distinct git objects with distinct SHAs. This matters especially for signed commits — tampering with the header order would invalidate the gpgsig block.

Convenience accessors (tree/1, parents/1, author/1, committer/1, gpgsig/1) extract well-known headers. Arbitrary headers (e.g. encoding, mergetag, HG:rename) are preserved in the :headers list but have no dedicated accessor.

Summary

Types

header()

@type header() :: {name :: String.t(), value :: String.t()}

t()

@type t() :: %Exgit.Object.Commit{headers: [header()], message: String.t()}

Functions

author(c)

@spec author(t()) :: String.t()

committer(c)

@spec committer(t()) :: String.t()

decode(bytes)

@spec decode(binary()) :: {:ok, t()} | {:error, term()}

encode(commit)

@spec encode(t()) :: iolist()

gpgsig(commit)

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

new(opts)

@spec new(keyword()) :: t()

parents(commit)

@spec parents(t()) :: [binary()]

sha(commit)

@spec sha(t()) :: Exgit.Object.sha()

sha_hex(commit)

@spec sha_hex(t()) :: String.t()

tree(c)

@spec tree(t()) :: binary()