.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Code::TidyAll::Git::Prereceive 3pm" .TH Code::TidyAll::Git::Prereceive 3pm "2017-01-06" "perl v5.24.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::Git::Prereceive \- Git pre\-receive hook that requires files to be tidyall'd .SH "VERSION" .IX Header "VERSION" version 0.55 .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" .IP "check (key/value params...)" 4 .IX Item "check (key/value params...)" An all-in-one class 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. .Sp .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 .Sp 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. .Sp 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"): .Sp .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 .Sp Or you can disable the hook in the repo being pushed to, e.g. by renaming \&.git/hooks/pre\-receive. .Sp If an unexpected runtime error occurs, it is reported but by default the commit will be allowed through (see \*(L"reject_on_error\*(R"). .Sp Passes mode = \*(L"commit\*(R" by default; see modes. .Sp Key/value parameters: .RS 4 .IP "allow_repeated_push" 4 .IX Item "allow_repeated_push" 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 undef to disable this feature. .IP "conf_name" 4 .IX Item "conf_name" Conf file name to search for instead of the defaults. .IP "extra_conf_files" 4 .IX Item "extra_conf_files" A listref 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 "git_path" 4 .IX Item "git_path" 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 "reject_on_error" 4 .IX Item "reject_on_error" 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 "tidyall_class" 4 .IX Item "tidyall_class" Subclass to use instead of Code::TidyAll .IP "tidyall_options" 4 .IX Item "tidyall_options" 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. .RE .RS 4 .RE .IP "new (key/value params...)" 4 .IX Item "new (key/value params...)" Constructor. Takes the same parameters documented in \fIcheck()\fR, above, and returns a new object which you can then call \*(L"check_input\*(R" on. .IP "check_input (input)" 4 .IX Item "check_input (input)" Run a check on \fIinput\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, undef if 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 through . .PP I am also usually active on \s-1IRC\s0 as 'drolsky' on \f(CW\*(C`irc://irc.perl.org\*(C'\fR. .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 \- 2016 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.