1 个不稳定版本

0.1.0 2019年8月9日

#18 in #传统

MIT/Apache

11KB
189

传统提交

一个用于 传统提交规范 的 Rust 解析器库。

工作进行中

该解析器目前还不完全符合规范,因为规范仍在测试版,可能会引入一些变化。

一旦规范达到 1.0 版本,并且解析器完全符合规范,该库将被标记为 v1.0.0


lib.rs:

一个用于 传统提交规范 的解析器库。

示例

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(())
}

依赖项

~1MB
~16K SLoC