++ed by:

8 PAUSE users
1 non-PAUSE user.

Gustavo Leite de Mendonça Chaves


Git::Hooks::CheckLog - Git::Hooks plugin to enforce commit log policies.


version 0.031


This Git::Hooks plugin can act as any of the below hooks to enforce policies on the commit log messages.


This hook is invoked during the commit, to check if the commit log message complies.


This hook is invoked multiple times in the remote repository during git push, once per branch being updated, to check if the commit log messages of all commits being pushed comply.


This hook is invoked once in the remote repository during git push, to check if the commit log messages of all commits being pushed comply.

Projects using Git, probably more than projects using any other version control system, have a tradition of establishing policies on the format of commit log messages. The REFERENCES section below lists some of the more important ones.

This plugin allows one to enforce most of the more established policies. The default configuration already enforces the most common one.

To enable the plugin you should define the appropriate Git configuration option like one of these:

    git config --add githooks.commit-msg  CheckLog
    git config --add githooks.pre-receive CheckLog
    git config --add githooks.update      CheckLog


Git::Hooks::CheckLog - Git::Hooks plugin to enforce commit log policies.


The plugin is configured by the following git options.

githooks.checklog..title-required [01]

The first line of a Git commit log message is usually called the 'title'. It must be separated by the rest of the message (it's 'body') by one empty line. This option, which is 1 by default, makes the plugin check if there is a proper title in the log message.

githooks.checklog..title-max-width N

This option specifies a limit to the width of the title's in characters. It's 50 by default. If you set it to 0 the plugin imposes no limit on the title's width.

githooks.checklog..title-period [deny|allow|require]

This option defines the policy regarding the title's ending in a period (a.k.a. full stop ('.')). It can take three values:


This means that the title SHOULD NOT end in a period. This is the default value of the option, as this is the most common policy.


This means that the title MAY end in a period, i.e., it doesn't matter.


This means that the title SHOULD end in a period.

githooks.checklog..body-max-width N

This option specifies a limit to the width of the commit log message's body lines, in characters. It's 72 by default. If you set it to 0 the plugin imposes no limit on the body line's width.

githooks.checklog..match [!]REGEXP

This option may be specified more than once. It defines a list of regular expressions that will be matched against the commit log messages. If the '!' prefix isn't used, the log has to match the REGEXP. Otherwise, the log must not match the REGEXP.

githooks.checklog..spelling [01]

This option makes the plugin spell check the commit log message using Text::SpellChecker. Any spell error will cause the commit or push to abort.

Note that Text::SpellChecker isn't required to install Git::Hooks. So, you may see errors when you enable this check. Please, refer to the module's own documentation to see how to install it and its own dependencies (which are Text::Hunspell or Text::Aspell).

githooks.checklog..spelling-lang ISO

The Text::SpellChecker module uses defaults to infer which language is must use to spell check the message. You can make it use a particular language passing its ISO code to this option.

i18n.commitEncoding ENCODING

This is not a CheckLog option. In fact, this is a native option of Git, which semantics is defined in git help config. It tells Git which character encoding the commit messages are stored in and defaults to utf-8.

When this plugin is used in the commit-msg hook, the message file is read and its contents are checked against the encoding specified by this option.


This module exports the following routines that can be used directly without using all of Git::Hooks infrastructure.

check_message_file GIT, MSGFILE

This is the routine used to implement the commit-msg hook. It needs a Git::More object and the name of a file containing the commit message.

check_affected_refs GIT

This is the routing used to implement the update and the pre-receive hooks. It needs a Git::More object.


git-commit(1) Manual Page

(http://www.kernel.org/pub/software/scm/git/docs/git-commit.html) This Git manual page has a section called DISCUSSION which discusses some common log message policies.

Linus Torvalds GitHub rant

(https://github.com/torvalds/linux/pull/17#issuecomment-5659933) In this note, Linus says why he dislikes GitHub's pull request interface, mainly because it doesn't allow him to enforce log message formatting policies.

MediaWiki Git/Commit message guidelines

(http://www.mediawiki.org/wiki/Git/Commit_message_guidelines) This document defines the MediaWiki's project commit log message guidelines.

Proper Git Commit Messages and an Elegant Git History

(http://ablogaboutcode.com/2011/03/23/proper-git-commit-messages-and-an-elegant-git-history/) This is a good discussion about commit log message formatting and the reasons behind them.


Gustavo L. de M. Chaves <gnustavo@cpan.org>


This software is copyright (c) 2013 by CPqD <www.cpqd.com.br>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.