Git::MoreHooks::CheckIndent - Check committed files for problems with indentation.
version 0.005
Use package via Git::Hooks interface (git config file).
This plugin allows user to enforce policies on the committed files. It can define allowed indentation characters (space/tab/both), tab width (1, 2, 3, 4, [..] characters) and on which files or file types to apply which rules.
Package Git::MoreHooks is currently being developed so changes in the existing hooks are possible.
To enable CheckIndent plugin, you need to add it to the githooks.plugin configuration option:
git config --add githooks.plugin CheckIndent
Git::Hooks::CheckIndent plugin hooks itself to the hooks below:
pre-commit
This hook is invoked during the commit.
update
This hook is invoked multiple times in the remote repository during git push, once per branch being updated.
git push
pre-receive
This hook is invoked once in the remote repository during git push.
ref-update
This hook is invoked when a push request is received by Gerrit Code Review.
patchset-created
This hook is invoked when a push request is received by Gerrit Code Review for a virtual branch (refs/for/*).
draft-published
The draft-published hook is executed when the user publishes a draft change, making it visible to other users.
This plugin is configured by the following git options.
A regular expressions matches against the file name. If config has several file items they are used in their order of appearance until a match is found. When a match is found, the parameters are applied to check the file.
Parameters are indent-char (allowed values: space, tab, both) and indent-size (allowed content: an integer number).
space
tab
both
file = ^proj1/old/.* indent-char:both indent-size:2 file = \.(c|h|cpp|hpp)$ indent-char:tab file = \.py$ indent-char:space indent-size:4
N.B. The file name is a regular expression which will be matched against the whole path of the file. The file name is not a File::Glob pattern (like Git::Hooks::CheckFile uses).
Sometimes we have to make exceptions. After finding the faulty lines ever line is matched against the exceptions. If a match is found, then error is not generated.
The first regular expression is matched against the name of the current file. The second is matched against the row on which an error was found.
This module exports the following routines that can be used directly without using all of Git::Hooks infrastructure.
This is the routine used to implement the pre-commit hook. It needs a Git::More object.
Git::More
This is the routine used to implement the pre-commit hook. It needs a Git::More object and a commit hash from Git::More::get_commit().
Git::More::get_commit()
This is the routing used to implement the update and the pre-receive hooks. It needs a Git::More object.
This is the routine used to implement the patchset-created Gerrit hook. It needs a Git::More object and the hash containing the arguments passed to the hook by Gerrit.
Thanks go to Gustavo Leite de Mendonça Chaves for his Git::Hooks package.
'Mikko Koivunalho <mikko.koivunalho@iki.fi>'
This software is copyright (c) 2015 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Git::MoreHooks, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::MoreHooks
CPAN shell
perl -MCPAN -e shell install Git::MoreHooks
For more information on module installation, please visit the detailed CPAN module installation guide.