[][src]Crate conventional_commit

A parser library for the Conventional Commit specification.

Example

use conventional_commit::{ConventionalCommit, Error};
use std::str::FromStr;

fn main() -> Result<(), Error> {
    let message = "\
    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.
    ";

    let commit = ConventionalCommit::from_str(message)?;

    assert_eq!(commit.type_(), "docs");
    assert_eq!(commit.scope(), Some("example"));
    assert_eq!(commit.description(), "add tested usage example");
    assert!(commit.body().unwrap().contains("helps people understand"));
    assert!(commit.breaking_change().unwrap().contains("That sounds like a change"));
}

Structs

ConventionalCommit

A conventional commit.

Enums

Error

All possible errors returned when parsing a conventional commit.