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::perf,
51 clippy::style,
52 clippy::suspicious,
53 non_fmt_panics
54)]
55#![allow(clippy::multiple_crate_versions)]
56
57#[cfg(test)]
58#[macro_use(quickcheck)]
59extern crate quickcheck_macros;
60
61pub use bodies::Bodies;
62pub use body::Body;
63pub use comment::Comment;
64pub use comments::Comments;
65pub use commit_message::{CommitMessage, Error as CommitMessageError};
66pub use fragment::Fragment;
67pub use scissors::Scissors;
68pub use subject::Subject;
69pub use trailer::{Error as TrailerError, Trailer};
70pub use trailers::Trailers;
71
72mod bodies;
73mod body;
74mod comment;
75mod comments;
76mod commit_message;
77mod fragment;
78mod scissors;
79mod subject;
80mod trailer;
81mod trailers;
82
83#[cfg(doctest)]
84mod test_readme {
85 macro_rules! external_doc_test {
86 ($x:expr) => {
87 #[doc = $x]
88 unsafe extern "C" {}
89 };
90 }
91
92 external_doc_test!(include_str!("../README.md"));
93}