1Code::TidyAll::Git::PreUrseecreiCvoen(t3r)ibuted Perl DoCcoudmee:n:tTaitdiyoAnll::Git::Prereceive(3)
2
3
4

NAME

6       Code::TidyAll::Git::Prereceive - Git pre-receive hook that requires
7       files to be tidyall'd
8

VERSION

10       version 0.78
11

SYNOPSIS

13         In .git/hooks/pre-receive:
14
15           #!/usr/bin/perl
16           use Code::TidyAll::Git::Prereceive;
17           use strict;
18           use warnings;
19
20           Code::TidyAll::Git::Prereceive->check();
21
22
23           # or
24
25           my $input = do { local $/; <STDIN> };
26
27           # Do other things with $input here
28
29           my $hook = Code::TidyAll::Git::Prereceive->new();
30           if (my $error = $hook->check_input($input)) {
31               die $error;
32           }
33

DESCRIPTION

35       This module implements a Git pre-receive hook <http://git-
36       scm.com/book/en/Customizing-Git-Git-Hooks> that checks if all pushed
37       files are tidied and valid according to tidyall, and rejects the push
38       if not.
39
40       This is typically used to validate pushes from multiple developers to a
41       shared repo, possibly on a remote server.
42
43       See also Code::TidyAll::Git::Precommit, which operates locally.
44

METHODS

46       This class provides the following methods:
47
48   Code::TidyAll::Git::Prereceive->check(%params)
49       This method reads commit info from standard input, then checks that all
50       files being added or modified in this push are tidied and valid
51       according to tidyall. If not, then the entire push is rejected and the
52       reason(s) are output to the client. e.g.
53
54           % git push
55           Counting objects: 9, done.
56           ...
57           remote: [checked] lib/CHI/Util.pm
58           remote: Code before strictures are enabled on line 13 [TestingAndDebugging::RequireUseStrict]
59           remote:
60           remote: 1 file did not pass tidyall check
61           To ...
62            ! [remote rejected] master -> master (pre-receive hook declined)
63
64       The configuration file ("tidyall.ini" or ".tidyallrc") must be checked
65       into git in the repo root directory, i.e. next to the .git directory.
66
67       In an emergency the hook can be bypassed by pushing the exact same set
68       of commits 3 consecutive times (configurable via
69       "allow_repeated_push"):
70
71           % git push
72           ...
73           remote: 1 file did not pass tidyall check
74
75           % git push
76           ...
77           *** Identical push seen 2 times
78           remote: 1 file did not pass tidyall check
79
80           % git push
81           ...
82           *** Identical push seen 3 times
83           *** Allowing push to proceed despite errors
84
85       Or you can disable the hook in the repo being pushed to, e.g. by
86       renaming .git/hooks/pre-receive.
87
88       If an unexpected runtime error occurs, it is reported but by default
89       the commit will be allowed through (see "reject_on_error").
90
91       Passes mode = "commit" by default; see modes.
92
93       Key/value parameters:
94
95       •   allow_repeated_push
96
97           Number of times a push must be repeated exactly after which it will
98           be let through regardless of errors. Defaults to 3. Set to 0 or
99           "undef" to disable this feature.
100
101       •   conf_name
102
103           Conf file name to search for instead of the defaults.
104
105       •   extra_conf_files
106
107           An arrayref of extra configuration files referred to from the main
108           configuration file, e.g.
109
110               extra_conf_files => ['perlcriticrc', 'perltidyrc']
111
112           These files will be pulled out of the repo alongside the main
113           configuration file. If you don't list them here then you'll get
114           errors like 'cannot find perlcriticrc' when the hook runs.
115
116       •   git_path
117
118           Path to git to use in commands, e.g. '/usr/bin/git' or
119           '/usr/local/bin/git'. By default, just uses 'git', which will
120           search the user's PATH.
121
122       •   reject_on_error
123
124           Whether "check" should reject the commit when an unexpected runtime
125           error occurs. By default, the error will be reported but the commit
126           will be allowed.
127
128       •   tidyall_class
129
130           Subclass to use instead of Code::TidyAll
131
132       •   tidyall_options
133
134           Hashref of options to pass to the Code::TidyAll constructor. You
135           can use this to override the default options
136
137               mode  => 'commit',
138               quiet => 1,
139
140           or pass additional options.
141
142   Code::TidyAll::Git::Prereceive->new(%params)
143       This takes the same parameters documented as documented in "check"
144       above and returns a new object which you can then call "check_input"
145       on.
146
147   $prereceive->check_input($input)
148       Runs a check on $input, the text block of lines that came from standard
149       input. You can call this manually before or after you do other
150       processing on the input. Returns an error string if there was a problem
151       or undef if there were no problems.
152

KNOWN BUGS

154       This hook will ignore any files with only a single line of content (no
155       newlines), as an imperfect way of filtering out symlinks.
156

SUPPORT

158       Bugs may be submitted at
159       <https://github.com/houseabsolute/perl-code-tidyall/issues>.
160
161       I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".
162

SOURCE

164       The source code repository for Code-TidyAll can be found at
165       <https://github.com/houseabsolute/perl-code-tidyall>.
166

AUTHORS

168       •   Jonathan Swartz <swartz@pobox.com>
169
170       •   Dave Rolsky <autarch@urth.org>
171
173       This software is copyright (c) 2011 - 2020 by Jonathan Swartz.
174
175       This is free software; you can redistribute it and/or modify it under
176       the same terms as the Perl 5 programming language system itself.
177
178       The full text of the license can be found in the LICENSE file included
179       with this distribution.
180
181
182
183perl v5.34.0                      2021-07-22 Code::TidyAll::Git::Prereceive(3)
Impressum