#git #commit #lints

mit-lint

Lints for commits parsed with mit-commit

31 releases (stable)

new 3.2.3 Jan 30, 2023
3.2.2 Oct 29, 2022
3.1.1 Aug 2, 2022
3.1.0 Jul 25, 2022
0.2.0 Sep 25, 2021

#1034 in Development tools

Download history 910/week @ 2022-10-13 280/week @ 2022-10-20 226/week @ 2022-10-27 375/week @ 2022-11-03 288/week @ 2022-11-10 188/week @ 2022-11-17 86/week @ 2022-11-24 545/week @ 2022-12-01 129/week @ 2022-12-08 337/week @ 2022-12-15 180/week @ 2022-12-22 68/week @ 2022-12-29 89/week @ 2023-01-05 152/week @ 2023-01-12 478/week @ 2023-01-19 447/week @ 2023-01-26

1,168 downloads per month
Used in 8 crates (3 directly)

CC0 license

205KB
5.5K SLoC

mit-lint

Lint commit messages

Example

use mit_commit::CommitMessage;
use mit_lint::{Code, lint, Problem, Lints, Lint};

let message:String = "x".repeat(73).into();
let expected = vec![Problem::new(
    "Your subject is longer than 72 characters".into(),
    "It's important to keep the subject of the commit less than 72 characters because when you look at the git log, that's where it truncates the message. This means that people won't get the entirety of the information in your commit.\n\nPlease keep the subject line 72 characters or under"
        .into(),
    Code::SubjectLongerThan72Characters,&message.clone().into(),Some(vec![(String::from("Too long"), 72, 1)]),
    Some("https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines".parse().unwrap()),
)];
let actual = lint(&CommitMessage::from(message), Lints::new(vec![Lint::SubjectLongerThan72Characters].into_iter().collect()));
assert_eq!(
    actual, expected,
    "Expected {:?}, found {:?}",
    expected, actual
);

Docs

Read more at Docs.rs

Dependencies

~8.5MB
~185K SLoC