Expand description
§Conventional commit parser
A rust implementation of the conventional commit specification. This crate expose functions to parse conventional commit messages.
§Example :
use conventional_commit_parser::parse;
use conventional_commit_parser::commit::*;
let message = r#"fix: correct minor typos in code
see the issue for details
on typos fixed.
Reviewed-by: Z
Refs #133"#;
let conventional_commit = parse(message)?;
assert_eq!(conventional_commit.commit_type, CommitType::BugFix);
assert_eq!(conventional_commit.summary, "correct minor typos in code".to_string());
assert_eq!(conventional_commit.body, Some(r#"see the issue for details
on typos fixed."#.to_string()));
assert_eq!(conventional_commit.footers, vec![
Footer {
token: "Reviewed-by".to_string(),
content: "Z".to_string(),
token_separator: Separator::Colon
},
Footer {
token: "Refs".to_string(),
content: "133".to_string(),
token_separator: Separator::Hash
}
]);
Modules§
Enums§
Functions§
- parse
- Parse a commit message into a
commit::ConventionalCommit
- parse_
body - Parse a commit body only returning an
Option<String>
on a non empty trimmed value - parse_
footers - Parse commit footers only
- parse_
summary - Parse a commit summary of the following form :
<type>[optional scope]: <description>
Returns aConventionalCommit
struct with aNone
body and empty footers.