mit_commit/lib.rs
1//! A library to parse commit messages in git hooks
2//!
3//! Make it a bit easier to write lints and for git hooks
4//!
5//! # Example
6//!
7//! ```
8//! use indoc::indoc;
9//! use mit_commit::{Bodies, CommitMessage, Subject};
10//!
11//! let message = CommitMessage::from(indoc!(
12//! "
13//! Update bashrc to include kubernetes completions
14//!
15//! This should make it easier to deploy things for the developers.
16//! Benchmarked with Hyperfine, no noticable performance decrease.
17//!
18//! ; Bitte geben Sie eine Commit-Beschreibung f\u{00FC}r Ihre \u{00E4}nderungen ein. Zeilen,
19//! ; die mit ';' beginnen, werden ignoriert, und eine leere Beschreibung
20//! ; bricht den Commit ab.
21//! ;
22//! ; Datum: Sat Jun 27 21:40:14 2020 +0200
23//! ;
24//! ; Auf Branch master
25//! ;
26//! ; Initialer Commit
27//! ;
28//! ; Zum Commit vorgemerkte \u{00E4}nderungen:
29//! ; neue Datei: .bashrc
30//! ;"
31//! ));
32//! assert_eq!(
33//! message.get_subject(),
34//! Subject::from("Update bashrc to include kubernetes completions")
35//! )
36//! ```
37
38#![warn(clippy::nursery)]
39#![deny(
40 unused,
41 nonstandard_style,
42 future_incompatible,
43 missing_copy_implementations,
44 missing_debug_implementations,
45 missing_docs,
46 clippy::pedantic,
47 clippy::cargo,
48 clippy::complexity,
49 clippy::correctness,
50 clippy::pedantic,
51 clippy::perf,
52 clippy::style,
53 clippy::suspicious,
54 non_fmt_panics
55)]
56#![allow(clippy::multiple_crate_versions)]
57
58#[cfg(test)]
59#[macro_use(quickcheck)]
60extern crate quickcheck_macros;
61
62pub use bodies::Bodies;
63pub use body::Body;
64pub use comment::Comment;
65pub use comments::Comments;
66pub use commit_message::{CommitMessage, Error as CommitMessageError};
67pub use fragment::Fragment;
68pub use scissors::Scissors;
69pub use subject::Subject;
70pub use trailer::{Error as TrailerError, Trailer};
71pub use trailers::Trailers;
72
73mod bodies;
74mod body;
75mod comment;
76mod comments;
77mod commit_message;
78mod fragment;
79mod scissors;
80mod subject;
81mod trailer;
82mod trailers;
83
84#[cfg(doctest)]
85mod test_readme {
86 macro_rules! external_doc_test {
87 ($x:expr) => {
88 #[doc = $x]
89 unsafe extern "C" {}
90 };
91 }
92
93 external_doc_test!(include_str!("../README.md"));
94}