git-lint - lint git commits and messages
git-lint [--check commit] [--check message <message_file>] [--profile <name>] [--version] [--help]
git-lint is the commandline interface to Git::Lint, a pluggable framework for linting git commits and messages.
git-lint
Run either check type commit or message.
commit
message
If check type is message, git-lint expects the file path of the commit message to check as an unnamed option.
git-lint --check message message_file
Run a specific profile of check modules.
Defaults to the 'default' profile.
Print the version.
Print the help menu.
git-lint has 2 check modes, commit and message.
The commit check mode checks each line of the commit diff for issues defined in the commit check modules.
The message check mode checks the commit message for issues defined in the message check modules.
Configuration is done through git config files (~/.gitconfig or /repo/.git/config).
git config
Only one profile, default, is defined internally. default contains all check modules by default.
default
The default profile can be overridden through git config files (~/.gitconfig or /repo/.git/config).
To set the default profile to only run the Whitespace commit check:
Whitespace
[lint "profiles.commit"] default = Whitespace
Or set the default profile to Whitespace and the fictional commit check, Flipdoozler:
Flipdoozler
[lint "profiles.commit"] default = Whitespace, Flipdoozler
Additional profiles can be added with a new name and list of checks to run.
[lint "profiles.commit"] default = Whitespace, Flipdoozler hardcore = Other, Module, Names
Message check profiles can also be defined.
[lint "profiles.message"] # override the default profile to only contain SummaryLength, SummaryEndingPeriod, and BlankLineAfterSummary default = SummaryLength, SummaryEndingPeriod, BlankLineAfterSummary # create a summary profile with specific modules summary = SummaryEndingPeriod, SummaryLength
An example configuration is provided in the examples directory of this project.
examples
To enable as a pre-commit hook, copy the pre-commit script from the example/hooks directory into the .git/hooks directory of the repo you want to check.
pre-commit
example/hooks
.git/hooks
Once copied, update the path and options to match your path and preferred profile.
To enable as a commit-msg hook, copy the commit-msg script from the example/hooks directory into the .git/hooks directory of the repo you want to check.
commit-msg
Copyright (c) 2022 Blaine Motsinger under the MIT license.
Blaine Motsinger blaine@renderorange.com
blaine@renderorange.com
To install Git::Lint, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Lint
CPAN shell
perl -MCPAN -e shell install Git::Lint
For more information on module installation, please visit the detailed CPAN module installation guide.