[libcode-tidyall-perl] 133/374: add emergency_comment_prefix ("NO TIDYALL" by default)
Jonas Smedegaard
js at alioth.debian.org
Sun Sep 29 22:26:04 UTC 2013
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libcode-tidyall-perl.
commit 7df559aca1a944585dca598867a5c58ec0244c93
Author: Jonathan Swartz <swartz at pobox.com>
Date: Mon Aug 6 00:20:36 2012 -0700
add emergency_comment_prefix ("NO TIDYALL" by default)
---
lib/Code/TidyAll/SVN/Precommit.pm | 55 +++++++++++++++++++++++++++++--------
lib/Code/TidyAll/t/SVN.pm | 6 ++++
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/lib/Code/TidyAll/SVN/Precommit.pm b/lib/Code/TidyAll/SVN/Precommit.pm
index 6bfc74a..eb836c8 100644
--- a/lib/Code/TidyAll/SVN/Precommit.pm
+++ b/lib/Code/TidyAll/SVN/Precommit.pm
@@ -8,17 +8,18 @@ use SVN::Look;
use Try::Tiny;
# Public
-has 'conf_file' => ( is => 'ro', default => sub { "tidyall.ini" } );
-has 'extra_conf_files' => ( is => 'ro', default => sub { [] } );
-has 'reject_on_error' => ( is => 'ro' );
-has 'repos' => ( is => 'ro', default => sub { $ARGV[0] } );
-has 'tidyall_class' => ( is => 'ro', default => sub { 'Code::TidyAll' } );
-has 'tidyall_options' => ( is => 'ro', default => sub { {} } );
-has 'txn' => ( is => 'ro', default => sub { $ARGV[1] } );
+has 'conf_file' => ( is => 'ro', default => sub { "tidyall.ini" } );
+has 'emergency_comment_prefix' => ( is => 'ro', default => sub { "NO TIDYALL" } );
+has 'extra_conf_files' => ( is => 'ro', default => sub { [] } );
+has 'reject_on_error' => ( is => 'ro' );
+has 'repos' => ( is => 'ro', default => sub { $ARGV[0] } );
+has 'tidyall_class' => ( is => 'ro', default => sub { 'Code::TidyAll' } );
+has 'tidyall_options' => ( is => 'ro', default => sub { {} } );
+has 'txn' => ( is => 'ro', default => sub { $ARGV[1] } );
# Private
has 'cat_file_cache' => ( init_arg => undef, is => 'ro', default => sub { {} } );
-has 'revlook' => ( init_arg => undef, is => 'lazy' );
+has 'revlook' => ( init_arg => undef, is => 'lazy' );
sub _build_revlook {
my $self = shift;
@@ -32,6 +33,15 @@ sub check {
try {
my $self = $class->new(%params);
+ my $revlook = $self->revlook;
+
+ # Skip if emergency comment prefix is present
+ #
+ if (my $prefix = $self->emergency_comment_prefix) {
+ if (index($revlook->log_msg, $prefix) == 0) {
+ return;
+ }
+ }
my @files = ( $self->revlook->added(), $self->revlook->updated() );
$log->info("----------------------------");
@@ -194,13 +204,21 @@ commit is rejected and the reason(s) are output to the client. e.g.
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> by default) 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 C<tidyall.ini> 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 a team from committing code.
+By default, if C<tidyall.ini> 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>.
@@ -212,6 +230,15 @@ Key/value parameters:
Name of configuration file, defaults to C<tidyall.ini>
+=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 configuration files referred to from C<tidyall.ini>, e.g.
@@ -257,4 +284,10 @@ adapters|Log::Any::Adapter>.
Having a log file is especially useful with precommit hooks since there is no
way for the hook to send back output on a successful commit.
+=head1 ACKNOWLEDGEMENTS
+
+Thanks to Alexander Simakov, author of
+L<perlcritic-checker|http://search.cpan.org/~xdr/perlcritic-checker-1.2.6/>,
+for some of the ideas here such as emergency_comment_prefix.
+
=cut
diff --git a/lib/Code/TidyAll/t/SVN.pm b/lib/Code/TidyAll/t/SVN.pm
index e601c35..e6d0231 100644
--- a/lib/Code/TidyAll/t/SVN.pm
+++ b/lib/Code/TidyAll/t/SVN.pm
@@ -92,6 +92,12 @@ sub test_svn : Tests {
};
unlike( $stderr, qr/\S/ );
$committed->();
+
+ write_file( "$work_dir/foo.txt", "def" );
+ $stderr =
+ capture_stderr { system( sprintf( 'svn -q commit -m "NO TIDYALL - emergency fix!" %s/foo.txt', $work_dir ) ) };
+ unlike( $stderr, qr/\S/ );
+ $committed->();
}
$precommit_hook_template = '#!/usr/bin/perl
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git
More information about the Pkg-perl-cvs-commits
mailing list