Commit
A parsed Conventional Commits 1.0.0 message:
type(scope)!: description, then an optional body and optional footers.
The parser follows the specification: the header is type, an optional (scope), an optional
! and : , then the description; a blank line separates the header from the body; footers
(Token: value or Token #value, with the token in words joined by - or exactly
BREAKING CHANGE) start at the first such line that follows a blank line and run to the end.
A commit is breaking when it has the ! or a BREAKING CHANGE footer. Text such as an
emoji before the description is part of the description.
Import
Section titled “Import”Cargo feature commit (enabled by default). To compile only this module:
or in Cargo.toml:
Definition
Section titled “Definition”Examples
Section titled “Examples”Methods
Section titled “Methods”Parses a commit message.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | &str | The whole message: header, then optionally a blank line, a body and footers. |
Returns
Result<Self, ParseCommitError>
Errors
A ParseCommitError when the message is empty, the header does not look like
type(scope): description, or the line after the header is not blank.
The commit type as written, such as "feat" or "fix".
Returns
&str — The type, without the scope or the !.
The scope between the parentheses.
Returns
Option<&str> — The scope, or None when there is none.
is_breaking
Section titled “is_breaking”Whether the commit is a breaking change: ! in the header or a BREAKING CHANGE footer.
Returns
bool — true for a breaking change.
description
Section titled “description”The description after the : , trimmed.
Returns
&str — The one-line summary.
The free-form body between the header and the footers.
Returns
Option<&str> — The body with its line breaks, or None when there is none.
footers
Section titled “footers”Every footer, in order, as (token, value).
Returns
&[(String, String)] — The footers, such as ("Refs", "42") or ("BREAKING CHANGE", "the API changed").
footer
Section titled “footer”The value of the first footer with the given token, ignoring case.
Parameters
| Parameter | Type | Description |
|---|---|---|
token | &str | The footer token, such as "Refs" or "BREAKING CHANGE". |
Returns
Option<&str> — The value, or None when there is no such footer.
The version bump this commit calls for under Semantic Versioning: Bump::Major for a
breaking change, Bump::Minor for feat, Bump::Patch for fix, otherwise
Bump::None. The type is matched ignoring case.
Returns
Bump — The bump level.
Error type: ParseCommitError
Section titled “Error type: ParseCommitError”Why a commit message is not a valid Conventional Commit.
