pub type Person {
Person(name: String, email: String, date: String)
} A commit author or committer identity — the name, email, and date carried on a commit.
silt / reference
The git object model: content-addressed blob, tree, and commit values with git-canonical SHA-1 ids, and the decoders that read their JSON bodies back into typed values. Pure logic over content — it owns no store.
import silt/object pub type Person {
Person(name: String, email: String, date: String)
} A commit author or committer identity — the name, email, and date carried on a commit.
pub type TreeEntry {
TreeEntry(
path: String,
mode: String,
kind: String,
size: Int,
sha: String,
)
}
A single entry within a tree object. kind is "blob" or "tree"; mode is the git file mode (default
"100644"); sha points at the child object.
pub type Commit {
Commit(
tree: String,
parents: List(String),
message: String,
author: Person,
committer: Person,
)
}
A decoded commit object: the tree it snapshots, its parents, the message, and the author /
committer identities.
pub fn object_id(
kind: String,
body: String,
) -> Result(String, Nil)
Compute the content-addressed id for an object body of the
given kind — the plural REST form "blobs",
"trees", or "commits".
Blobs use git-canonical framing ("blob " <len> \0 <content>") so the id matches a real git object id. Trees and commits hash their
serialized body directly. Any other kind is an
Error(Nil).
pub fn sha1(body: BitArray) -> String
The lowercase hex SHA-1 of the given bytes. The primitive under object_id, exposed for callers that already hold framed bytes.
pub fn blob_content(
content: String,
encoding: String,
) -> Result(BitArray, Nil)
Decode the raw bytes carried by a blob body given its declared encoding — "utf-8" or "base64". Any other encoding is
an Error(Nil).
pub fn decode_blob(
body: String,
) -> Result(#(String, String), Nil)
Decode a blob body into its #(content, encoding). A missing
encoding field defaults to "utf-8".
pub fn decode_tree(
body: String,
) -> Result(List(TreeEntry), Nil)
Decode a tree body into its TreeEntry list. Per-entry defaults: mode "100644",
type "blob", size 0.
pub fn decode_commit(
body: String,
) -> Result(Commit, Nil)
Decode a commit body into a Commit.
parents defaults to [], message to
"", and a missing committer falls back to the
author.
pub fn decode_ref(
body: String,
) -> Result(#(String, String), Nil)
Decode a ref-update body into its #(ref, sha) — the ref
name and the commit it should point at.