Git::Lint - lint git commits and messages
use Git::Lint; my $lint = Git::Lint->new(); $lint->run({ check => 'commit', profile => 'default' }); $lint->run({ check => 'message', file => 'file_path', profile => 'default' }); git-lint [--check commit] [--check message <message_file>] [--profile <name>] [--version] [--help]
Git::Lint is a pluggable framework for linting git commits and messages.
Git::Lint
For the commandline interface to Git::Lint, see the documentation for git-lint.
For adding check modules, see the documentation for Git::Lint::Check::Commit and Git::Lint::Check::Message.
Returns a reference to a new Git::Lint object.
Loads the check modules as defined by profile.
profile
run expects the following arguments:
run
The name of a defined set of check modules to run.
check
Either commit or message.
commit
message
file
If check is message, file is required.
Returns the Git::Lint::Config object created by Git::Lint.
To install Git::Lint, download the latest release, then extract.
tar xzvf Git-Lint-0.008.tar.gz cd Git-Lint-0.008
or clone the repo.
git clone https://github.com/renderorange/Git-Lint.git cd Git-Lint
Generate the build and installation tooling.
perl Makefile.PL
Then build, test, and install.
make make test && make install
Git::Lint can also be installed using cpanm.
cpanm Git::Lint
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
CPAN shell
perl -MCPAN -e shell install Git::Lint
For more information on module installation, please visit the detailed CPAN module installation guide.