.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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::Git::Prereceive 3pm" .TH Code::TidyAll::Git::Prereceive 3pm "2022-12-31" "perl v5.36.0" "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::Git::Prereceive \- Git pre\-receive hook that requires files to be tidyall'd .SH "VERSION" .IX Header "VERSION" version 0.83 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& In .git/hooks/pre\-receive: \& \& #!/usr/bin/perl \& use Code::TidyAll::Git::Prereceive; \& use strict; \& use warnings; \& \& Code::TidyAll::Git::Prereceive\->check(); \& \& \& # or \& \& my $input = do { local $/; }; \& \& # Do other things with $input here \& \& my $hook = Code::TidyAll::Git::Prereceive\->new(); \& if (my $error = $hook\->check_input($input)) { \& die $error; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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. .PP This is typically used to validate pushes from multiple developers to a shared repo, possibly on a remote server. .PP See also Code::TidyAll::Git::Precommit, which operates locally. .SH "METHODS" .IX Header "METHODS" This class provides the following methods: .SS "Code::TidyAll::Git::Prereceive\->check(%params)" .IX Subsection "Code::TidyAll::Git::Prereceive->check(%params)" 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. .PP .Vb 9 \& % git push \& Counting objects: 9, done. \& ... \& remote: [checked] lib/CHI/Util.pm \& remote: Code before strictures are enabled on line 13 [TestingAndDebugging::RequireUseStrict] \& remote: \& remote: 1 file did not pass tidyall check \& To ... \& ! [remote rejected] master \-> master (pre\-receive hook declined) .Ve .PP The configuration file (\f(CW\*(C`tidyall.ini\*(C'\fR or \f(CW\*(C`.tidyallrc\*(C'\fR) must be checked into git in the repo root directory, i.e. next to the .git directory. .PP In an emergency the hook can be bypassed by pushing the exact same set of commits 3 consecutive times (configurable via \*(L"allow_repeated_push\*(R"): .PP .Vb 3 \& % 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 .Ve .PP Or you can disable the hook in the repo being pushed to, e.g. by renaming \&.git/hooks/pre\-receive. .PP If an unexpected runtime error occurs, it is reported but by default the commit will be allowed through (see \*(L"reject_on_error\*(R"). .PP Passes mode = \*(L"commit\*(R" by default; see modes. .PP Key/value parameters: .IP "\(bu" 4 allow_repeated_push .Sp Number of times a push must be repeated exactly after which it will be let through regardless of errors. Defaults to 3. Set to 0 or \f(CW\*(C`undef\*(C'\fR to disable this feature. .IP "\(bu" 4 conf_name .Sp Conf file name to search for instead of the defaults. .IP "\(bu" 4 extra_conf_files .Sp An arrayref of extra configuration files referred to from the main configuration file, e.g. .Sp .Vb 1 \& extra_conf_files => [\*(Aqperlcriticrc\*(Aq, \*(Aqperltidyrc\*(Aq] .Ve .Sp These files will be pulled out of the repo alongside the main configuration file. If you don't list them here then you'll get errors like 'cannot find perlcriticrc' when the hook runs. .IP "\(bu" 4 git_path .Sp Path to git to use in commands, e.g. '/usr/bin/git' or '/usr/local/bin/git'. By default, just uses 'git', which will search the user's \s-1PATH.\s0 .IP "\(bu" 4 reject_on_error .Sp Whether \f(CW\*(C`check\*(C'\fR should reject the commit when an unexpected runtime error occurs. By default, the error will be reported but the commit will be allowed. .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. You can use this to override the default options .Sp .Vb 2 \& mode => \*(Aqcommit\*(Aq, \& quiet => 1, .Ve .Sp or pass additional options. .SS "Code::TidyAll::Git::Prereceive\->new(%params)" .IX Subsection "Code::TidyAll::Git::Prereceive->new(%params)" This takes the same parameters documented as documented in \f(CW\*(C`check\*(C'\fR above and returns a new object which you can then call \f(CW\*(C`check_input\*(C'\fR on. .ie n .SS "$prereceive\->check_input($input)" .el .SS "\f(CW$prereceive\fP\->check_input($input)" .IX Subsection "$prereceive->check_input($input)" Runs a check on \fI\f(CI$input\fI\fR, 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. .SH "KNOWN BUGS" .IX Header "KNOWN BUGS" This hook will ignore any files with only a single line of content (no newlines), as an imperfect way of filtering out symlinks. .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted at . .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 \- 2022 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.