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(
39    rust_2018_idioms,
40    unused,
41    rust_2021_compatibility,
42    nonstandard_style,
43    future_incompatible,
44    missing_copy_implementations,
45    missing_debug_implementations,
46    missing_docs
47)]
48
49#[cfg(test)]
50extern crate quickcheck;
51#[cfg(test)]
52#[macro_use(quickcheck)]
53extern crate quickcheck_macros;
54
55pub use bodies::Bodies;
56pub use body::Body;
57pub use comment::Comment;
58pub use comments::Comments;
59pub use commit_message::{CommitMessage, Error as CommitMessageError};
60pub use fragment::Fragment;
61pub use scissors::Scissors;
62pub use subject::Subject;
63pub use trailer::{Error as TrailerError, Trailer};
64pub use trailers::Trailers;
65
66mod bodies;
67#[cfg(test)]
68mod bodies_test;
69mod body;
70#[cfg(test)]
71mod body_test;
72mod comment;
73#[cfg(test)]
74mod comment_test;
75mod comments;
76#[cfg(test)]
77mod comments_test;
78mod commit_message;
79#[cfg(test)]
80mod commit_message_test;
81mod fragment;
82#[cfg(test)]
83mod fragment_test;
84mod scissors;
85#[cfg(test)]
86mod scissors_test;
87mod subject;
88#[cfg(test)]
89mod subject_test;
90mod trailer;
91#[cfg(test)]
92mod trailer_test;
93mod trailers;
94#[cfg(test)]
95mod trailers_test;
96
97#[cfg(doctest)]
98mod test_readme {
99    macro_rules! external_doc_test {
100        ($x:expr) => {
101            #[doc = $x]
102            extern "C" {}
103        };
104    }
105
106    external_doc_test!(include_str!("../README.md"));
107}