.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Code::TidyAll::SVN::Precommit 3pm" .TH Code::TidyAll::SVN::Precommit 3pm "2021-02-19" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Code::TidyAll::SVN::Precommit \- Subversion pre\-commit hook that requires files to be tidyall'd .SH "VERSION" .IX Header "VERSION" version 0.78 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& In hooks/pre\-commit in your svn repo: \& \& #!/usr/bin/perl \& use Code::TidyAll::SVN::Precommit; \& use Log::Any::Adapter (File => \*(Aq/path/to/hooks/logs/tidyall.log\*(Aq); \& use strict; \& use warnings; \& \& Code::TidyAll::SVN::Precommit\->check(); .Ve .SH "DESCRIPTION" .IX Header "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. .SH "METHODS" .IX Header "METHODS" This class provides the following methods: .SH "Code::TidyAll::SVN::Precommit\->check(%params)" .IX Header "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. .PP .Vb 10 \& % 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: *** \*(AqPerlTidy\*(Aq: needs tidying \& lib/CHI/Driver.pm: *** \*(AqPerlCritic\*(Aq: Code before strictures are enabled \& at /tmp/Code\-TidyAll\-0e6K/Driver.pm line 2 \& [TestingAndDebugging::RequireUseStrict] .Ve .PP In an emergency the hook can be bypassed by prefixing the comment with \*(L"\s-1NO TIDYALL\*(R",\s0 e.g. .PP .Vb 5 \& % 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. .Ve .PP The configuration file (\f(CW\*(C`tidyall.ini\*(C'\fR or \f(CW\*(C`.tidyallrc\*(C'\fR) 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. .PP By default, if the configuration file cannot be found, or if a runtime error occurs, a warning is logged (see \*(L"\s-1LOGGING\*(R"\s0 below) but the commit is allowed to proceed. This is so that unexpected problems do not prevent valid commits. .PP Passes mode = \*(L"commit\*(R" by default; see modes. .PP Key/value parameters: .IP "\(bu" 4 conf_name .Sp Conf file name to search for instead of the defaults. .IP "\(bu" 4 emergency_comment_prefix .Sp Commit prefix that will cause this hook to be bypassed. Defaults to \*(L"\s-1NO TIDYALL\*(R".\s0 e.g. .Sp .Vb 1 \& svn commit \-m "NO TIDYALL \- must get fix to production!" .Ve .Sp Set to a false value (e.g. blank or undefined) to disable bypassing. .IP "\(bu" 4 extra_conf_files .Sp A listref of other configuration files referred to from the main configuration file, e.g. .Sp .Vb 1 \& extra_conf_files => [\*(Aqperlcriticrc\*(Aq, \*(Aqperltidyrc\*(Aq] .Ve .Sp If you don't list them here then you'll get errors like 'cannot find perlcriticrc' when the hook runs. .IP "\(bu" 4 reject_on_error .Sp If the configuration file cannot be found for some/all the files, or if a runtime error occurs, reject the commit. .IP "\(bu" 4 repos .Sp Repository path being committed; defaults to \f(CW$ARGV[0]\fR .IP "\(bu" 4 tidyall_class .Sp Subclass to use instead of Code::TidyAll .IP "\(bu" 4 tidyall_options .Sp Hashref of options to pass to the Code::TidyAll constructor .IP "\(bu" 4 txn .Sp Commit transaction; defaults to \f(CW$ARGV[1]\fR .SH "LOGGING" .IX Header "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 .PP .Vb 1 \& use Log::Any::Adapter (File => "/path/to/hooks/logs/tidyall.log"); .Ve .PP or do something fancier with one of the other Log::Any adapters. .PP 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. .SH "ACKNOWLEDGMENTS" .IX Header "ACKNOWLEDGMENTS" Thanks to Alexander Simakov, author of perlcritic-checker , for some of the ideas here such as emergency_comment_prefix. .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted at . .PP I am also usually active on \s-1IRC\s0 as 'autarch' on \f(CW\*(C`irc://irc.perl.org\*(C'\fR. .SH "SOURCE" .IX Header "SOURCE" The source code repository for Code-TidyAll can be found at . .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Jonathan Swartz .IP "\(bu" 4 Dave Rolsky .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 \- 2020 by Jonathan Swartz. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .PP The full text of the license can be found in the \fI\s-1LICENSE\s0\fR file included with this distribution.