This class provides the following methods:
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.
% 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)
The configuration file ("tidyall.ini" or ".tidyallrc") must be checked into git in the repo root
directory, i.e. next to the .git directory.
In an emergency the hook can be bypassed by pushing the exact same set of commits 3 consecutive times
(configurable via "allow_repeated_push"):
% 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
Or you can disable the hook in the repo being pushed to, e.g. by renaming .git/hooks/pre-receive.
If an unexpected runtime error occurs, it is reported but by default the commit will be allowed through
(see "reject_on_error").
Passes mode = "commit" by default; see modes.
Key/value parameters:
• 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.
• conf_name
Conf file name to search for instead of the defaults.
• extra_conf_files
An arrayref of extra configuration files referred to from the main configuration file, e.g.
extra_conf_files => ['perlcriticrc', 'perltidyrc']
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.
• 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 PATH.
• reject_on_error
Whether "check" should reject the commit when an unexpected runtime error occurs. By default, the
error will be reported but the commit will be allowed.
• tidyall_class
Subclass to use instead of Code::TidyAll
• tidyall_options
Hashref of options to pass to the Code::TidyAll constructor. You can use this to override the default
options
mode => 'commit',
quiet => 1,
or pass additional options.
Code::TidyAll::Git::Prereceive->new(%params)
This takes the same parameters documented as documented in "check" above and returns a new object which
you can then call "check_input" on.
$prereceive->check_input($input)
Runs a check on $input, 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.