Expand description
A whole commit message: the header, the body, and the trailers under it.
The message is the rendering. What a worker states is a CommitMessage’s fields — a kind,
a scope, what it did, what it refers to — and the text git stores is derived from them.
That direction matters: the same value renders the commit, answers what a plan intends
to do before anything is written, and is what a validator judges after it is. A free-form
string as the canonical representation could do only the last of those.
use majordomus_cli::commit::{CommitHeader, CommitMessage};
use majordomus_cli::release::ChangeKind;
let m = CommitMessage::parse("fix(commit): the trailer is read\n\nWhy it was wrong.\n\nRefs: I1305\n");
assert_eq!(m.header.kind, ChangeKind::Fix);
assert_eq!(m.body, "Why it was wrong.");
assert_eq!(m.trailer("Refs"), Some("I1305"));
// and the value renders back to the message it was read from
assert!(m.render().starts_with("fix(commit): the trailer is read\n\nWhy it was wrong."));Structs§
- Commit
Message - A commit message taken apart: header, body, trailers.
- Commit
Trailer - One
Key: valueline in the trailer block at the end of a commit message.