++ed by:

20 PAUSE users
7 non-PAUSE users.

Dave Rolsky
and 18 contributors


Code::TidyAll::SVN::Precommit - Subversion pre-commit hook that requires files to be tidyall'd


version 0.57


  In hooks/pre-commit in your svn repo:

    use Code::TidyAll::SVN::Precommit;
    use Log::Any::Adapter (File => "/path/to/hooks/logs/tidyall.log");
    use strict;
    use warnings;



This module implements a Subversion pre-commit hook that checks if all files are tidied and valid according to tidyall, and rejects the commit if not.


check (key/value params...)

Class method. Check that all files being added or modified in this commit are tidied and valid according to tidyall. If not, then the entire commit is rejected and the reason(s) are output to the client. e.g.

    % svn commit -m "fixups" CHI.pm CHI/Driver.pm
    Sending        CHI/Driver.pm
    Sending        CHI.pm
    Transmitting file data ..svn: Commit failed (details follow):
    svn: Commit blocked by pre-commit hook (exit code 255) with output:
    2 files did not pass tidyall check
    lib/CHI.pm: *** 'PerlTidy': needs tidying
    lib/CHI/Driver.pm: *** 'PerlCritic': Code before strictures are enabled
      at /tmp/Code-TidyAll-0e6K/Driver.pm line 2

In an emergency the hook can be bypassed by prefixing the comment with "NO TIDYALL", e.g.

    % svn commit -m "NO TIDYALL - this is an emergency!" CHI.pm CHI/Driver.pm
    Sending        CHI/Driver.pm
    Sending        CHI.pm
    Transmitting file data .
    Committed revision 7562.

The configuration file (tidyall.ini or .tidyallrc) must be checked into svn. For each file, the hook will look upwards from the file's repo location and use the first configuration file it finds.

By default, if the configuration file cannot be found, or if a runtime error occurs, a warning is logged (see "LOGGING" below) but the commit is allowed to proceed. This is so that unexpected problems do not prevent valid commits.

Passes mode = "commit" by default; see modes.

Key/value parameters:


Conf file name to search for instead of the defaults.


Commit prefix that will cause this hook to be bypassed. Defaults to "NO TIDYALL". e.g.

    svn commit -m "NO TIDYALL - must get fix to production!"

Set to a false value (e.g. blank or undefined) to disable bypassing.


A listref of other configuration files referred to from the main configuration file, e.g.

    extra_conf_files => ['perlcriticrc', 'perltidyrc']

If you don't list them here then you'll get errors like 'cannot find perlcriticrc' when the hook runs.


If the configuration file cannot be found for some/all the files, or if a runtime error occurs, reject the commit.


Repository path being committed; defaults to $ARGV[0]


Subclass to use instead of Code::TidyAll


Hashref of options to pass to the Code::TidyAll constructor


Commit transaction; defaults to $ARGV[1]


This module uses Log::Any to log its activity, including all files that were checked, an inability to find the configuration file, and any runtime errors that occur. You can create a simple date-stamped log file with

    use Log::Any::Adapter (File => "/path/to/hooks/logs/tidyall.log");

or do something fancier with one of the other Log::Any adapters.

Having a log file is especially useful with pre-commit hooks since there is no way for the hook to send back output on a successful commit.


Thanks to Alexander Simakov, author of perlcritic-checker, for some of the ideas here such as emergency_comment_prefix.


Bugs may be submitted at https://github.com/houseabsolute/perl-code-tidyall/issues.

I am also usually active on IRC as 'autarch' on irc://irc.perl.org.


The source code repository for Code-TidyAll can be found at https://github.com/houseabsolute/perl-code-tidyall.


  • Jonathan Swartz <swartz@pobox.com>

  • Dave Rolsky <autarch@urth.org>


This software is copyright (c) 2011 - 2017 by Jonathan Swartz.

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

The full text of the license can be found in the LICENSE file included with this distribution.