Code-TidyAll
view release on metacpan or search on metacpan
lib/Code/TidyAll/SVN/Precommit.pm view on Meta::CPAN
}
catch {
$contents = '';
};
$self->cat_file_cache->{$file} = $contents;
}
return $contents;
}
1;
# ABSTRACT: Subversion pre-commit hook that requires files to be tidyall'd
__END__
=pod
=encoding UTF-8
=head1 NAME
Code::TidyAll::SVN::Precommit - Subversion pre-commit hook that requires files to be tidyall'd
=head1 VERSION
version 0.85
=head1 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();
=head1 DESCRIPTION
This module implements a L<Subversion pre-commit
hook|http://svnbook.red-bean.com/en/1.7/svn.ref.reposhooks.pre-commit.html>
that checks if all files are tidied and valid according to L<tidyall>, and
rejects the commit if not.
=head1 METHODS
This class provides the following methods:
=head1 Code::TidyAll::SVN::Precommit->check(%params)
Check that all files being added or modified in this commit are tidied and
valid according to L<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 (C<tidyall.ini> or C<.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 L</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 L<modes|tidyall/MODES>.
Key/value parameters:
=over 4
=item * conf_name
Conf file name to search for instead of the defaults.
=item * emergency_comment_prefix
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.
=item * extra_conf_files
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.
=item * reject_on_error
If the configuration file cannot be found for some/all the files, or if a
runtime error occurs, reject the commit.
=item * repos
Repository path being committed; defaults to C<< $ARGV[0] >>
( run in 0.826 second using v1.01-cache-2.11-cpan-39bf76dae61 )