View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Dave Rolsky > Code-TidyAll > Code::TidyAll::Git::Prereceive



Annotate this POD


View/Report Bugs
Module Version: 0.70   Source  


Code::TidyAll::Git::Prereceive - Git pre-receive hook that requires files to be tidyall'd


version 0.70


  In .git/hooks/pre-receive:

    use Code::TidyAll::Git::Prereceive;
    use strict;
    use warnings;


    # or

    my $input = do { local $/; <STDIN> };

    # Do other things with $input here

    my $hook = Code::TidyAll::Git::Prereceive->new();
    if (my $error = $hook->check_input($input)) {
        die $error;


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

This is typically used to validate pushes from multiple developers to a shared repo, possibly on a remote server.

See also Code::TidyAll::Git::Precommit, which operates locally.


This class provides the following methods:


This method reads commit info from standard input, then checks that all files being added or modified in this push are tidied and valid according to tidyall. If not, then the entire push is rejected and the reason(s) are output to the client. e.g.

    % git push
    Counting objects: 9, done.
    remote: [checked] lib/CHI/
    remote: Code before strictures are enabled on line 13 [TestingAndDebugging::RequireUseStrict]
    remote: 1 file did not pass tidyall check
    To ...
     ! [remote rejected] master -> master (pre-receive hook declined)

The configuration file (tidyall.ini or .tidyallrc) must be checked into git in the repo root directory, i.e. next to the .git directory.

In an emergency the hook can be bypassed by pushing the exact same set of commits 3 consecutive times (configurable via "allow_repeated_push"):

    % git push
    remote: 1 file did not pass tidyall check

    % git push
    *** Identical push seen 2 times
    remote: 1 file did not pass tidyall check

    % git push
    *** Identical push seen 3 times
    *** Allowing push to proceed despite errors

Or you can disable the hook in the repo being pushed to, e.g. by renaming .git/hooks/pre-receive.

If an unexpected runtime error occurs, it is reported but by default the commit will be allowed through (see "reject_on_error").

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

Key/value parameters:


This takes the same parameters documented as documented in check above and returns a new object which you can then call check_input on.


Runs a check on $input, the text block of lines that came from standard input. You can call this manually before or after you do other processing on the input. Returns an error string if there was a problem or undef if there were no problems.


This hook will ignore any files with only a single line of content (no newlines), as an imperfect way of filtering out symlinks.


Bugs may be submitted at

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


The source code repository for Code-TidyAll can be found at



This software is copyright (c) 2011 - 2018 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: