View on
MetaCPAN
Dave Rolsky > Code-TidyAll > Code::TidyAll::SVN::Precommit

Download:
Code-TidyAll-0.69.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.69   Source  

NAME ^

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

VERSION ^

version 0.69

SYNOPSIS ^

  In hooks/pre-commit in your svn repo:

    #!/usr/bin/perl
    use Code::TidyAll::SVN::Precommit;
    use Log::Any::Adapter (File => '/path/to/hooks/logs/tidyall.log');
    use strict;
    use warnings;

    Code::TidyAll::SVN::Precommit->check();

DESCRIPTION ^

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.

METHODS ^

This class provides the following methods:

Code::TidyAll::SVN::Precommit->check(%params) ^

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
      [TestingAndDebugging::RequireUseStrict]

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:

LOGGING ^

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.

ACKNOWLEDGMENTS ^

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

SUPPORT ^

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.

SOURCE ^

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

AUTHORS ^

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: