1 unstable release

0.1.0 Aug 9, 2019

#18 in #conventional

MIT/Apache

11KB
189 lines

Conventional Commit

A Rust parser library for the Conventional Commit spec.

Work in Progress

The parser does not 100% conform to the spec yet, and since the spec is still in beta, it is likely to still introduce some changes.

Once the spec hits 1.0, and the parser is fully compliant, this library will be tagged with v1.0.0 as well.


lib.rs:

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"));
    # Ok(())
}

Dependencies

~1MB
~16K SLoC