Crate git_conventional[−][src]
Expand description
A parser library for the Conventional Commit specification.
Example
use indoc::indoc; let message = indoc!(" docs(example)!: add tested usage example This example is tested using Rust's doctest capabilities. Having this example helps people understand how to use the parser. BREAKING CHANGE: Going from nothing to something, meaning anyone doing nothing before suddenly has something to do. That sounds like a change in your break. Co-Authored-By: Lisa Simpson <lisa@simpsons.fam> Closes #12 "); let commit = git_conventional::Commit::parse(message).unwrap(); // You can access all components of the subject. assert_eq!(commit.type_(), git_conventional::DOCS); assert_eq!(commit.scope().unwrap(), "example"); assert_eq!(commit.description(), "add tested usage example"); // And the free-form commit body. assert!(commit.body().unwrap().contains("helps people understand")); // If a commit is marked with a bang (`!`) OR has a footer with the key // "BREAKING CHANGE", it is considered a "breaking" commit. assert!(commit.breaking()); // You can access each footer individually. assert!(commit.footers()[0].value().contains("That sounds like a change")); // Footers provide access to their token and value. assert_eq!(commit.footers()[1].token(), "Co-Authored-By"); assert_eq!(commit.footers()[1].value(), "Lisa Simpson <lisa@simpsons.fam>"); // Two types of separators are supported, regular ": ", and " #": assert_eq!(commit.footers()[2].separator(), " #"); assert_eq!(commit.footers()[2].value(), "12");
Structs
Commit | A conventional commit. |
Error | The error returned when parsing a commit fails. |
Footer | A single footer. |
FooterToken | A component of the conventional commit. |
Scope | A component of the conventional commit. |
Type | A component of the conventional commit. |
Enums
ErrorKind | All possible error kinds returned when parsing a conventional commit. |
FooterSeparator | The type of separator between the footer token and value. |
Constants
CHORE | Possible commit type for other things. |
DOCS | Possible commit type for changing documentation. |
FEAT | Commit type when introducing new features (correlates with |
FIX | Commit type when patching a bug (correlates with |
PERF | Possible commit type for performance optimizations. |
REFACTOR | Possible commit type for refactoring code structure. |
REVERT | Possible commit type when reverting changes. |
STYLE | Possible commit type for changing code style. |
TEST | Possible commit type for addressing tests. |