1Code::TidyAll::SVN::PreUcsoemrmiCto(n3t)ributed Perl DocCuomdeen:t:aTtiidoynAll::SVN::Precommit(3)
2
3
4

NAME

6       Code::TidyAll::SVN::Precommit - Subversion pre-commit hook that
7       requires files to be tidyall'd
8

VERSION

10       version 0.83
11

SYNOPSIS

13         In hooks/pre-commit in your svn repo:
14
15           #!/usr/bin/perl
16           use Code::TidyAll::SVN::Precommit;
17           use Log::Any::Adapter (File => '/path/to/hooks/logs/tidyall.log');
18           use strict;
19           use warnings;
20
21           Code::TidyAll::SVN::Precommit->check();
22

DESCRIPTION

24       This module implements a Subversion pre-commit hook
25       <http://svnbook.red-bean.com/en/1.7/svn.ref.reposhooks.pre-commit.html>
26       that checks if all files are tidied and valid according to tidyall, and
27       rejects the commit if not.
28

METHODS

30       This class provides the following methods:
31

Code::TidyAll::SVN::Precommit->check(%params)

33       Check that all files being added or modified in this commit are tidied
34       and valid according to tidyall. If not, then the entire commit is
35       rejected and the reason(s) are output to the client. e.g.
36
37           % svn commit -m "fixups" CHI.pm CHI/Driver.pm
38           Sending        CHI/Driver.pm
39           Sending        CHI.pm
40           Transmitting file data ..svn: Commit failed (details follow):
41           svn: Commit blocked by pre-commit hook (exit code 255) with output:
42           2 files did not pass tidyall check
43           lib/CHI.pm: *** 'PerlTidy': needs tidying
44           lib/CHI/Driver.pm: *** 'PerlCritic': Code before strictures are enabled
45             at /tmp/Code-TidyAll-0e6K/Driver.pm line 2
46             [TestingAndDebugging::RequireUseStrict]
47
48       In an emergency the hook can be bypassed by prefixing the comment with
49       "NO TIDYALL", e.g.
50
51           % svn commit -m "NO TIDYALL - this is an emergency!" CHI.pm CHI/Driver.pm
52           Sending        CHI/Driver.pm
53           Sending        CHI.pm
54           Transmitting file data .
55           Committed revision 7562.
56
57       The configuration file ("tidyall.ini" or ".tidyallrc") must be checked
58       into svn. For each file, the hook will look upwards from the file's
59       repo location and use the first configuration file it finds.
60
61       By default, if the configuration file cannot be found, or if a runtime
62       error occurs, a warning is logged (see "LOGGING" below) but the commit
63       is allowed to proceed. This is so that unexpected problems do not
64       prevent valid commits.
65
66       Passes mode = "commit" by default; see modes.
67
68       Key/value parameters:
69
70       •   conf_name
71
72           Conf file name to search for instead of the defaults.
73
74       •   emergency_comment_prefix
75
76           Commit prefix that will cause this hook to be bypassed. Defaults to
77           "NO TIDYALL". e.g.
78
79               svn commit -m "NO TIDYALL - must get fix to production!"
80
81           Set to a false value (e.g. blank or undefined) to disable
82           bypassing.
83
84       •   extra_conf_files
85
86           A listref of other configuration files referred to from the main
87           configuration file, e.g.
88
89               extra_conf_files => ['perlcriticrc', 'perltidyrc']
90
91           If you don't list them here then you'll get errors like 'cannot
92           find perlcriticrc' when the hook runs.
93
94       •   reject_on_error
95
96           If the configuration file cannot be found for some/all the files,
97           or if a runtime error occurs, reject the commit.
98
99       •   repos
100
101           Repository path being committed; defaults to $ARGV[0]
102
103       •   tidyall_class
104
105           Subclass to use instead of Code::TidyAll
106
107       •   tidyall_options
108
109           Hashref of options to pass to the Code::TidyAll constructor
110
111       •   txn
112
113           Commit transaction; defaults to $ARGV[1]
114

LOGGING

116       This module uses Log::Any to log its activity, including all files that
117       were checked, an inability to find the configuration file, and any
118       runtime errors that occur. You can create a simple date-stamped log
119       file with
120
121           use Log::Any::Adapter (File => "/path/to/hooks/logs/tidyall.log");
122
123       or do something fancier with one of the other Log::Any adapters.
124
125       Having a log file is especially useful with pre-commit hooks since
126       there is no way for the hook to send back output on a successful
127       commit.
128

ACKNOWLEDGMENTS

130       Thanks to Alexander Simakov, author of perlcritic-checker
131       <http://search.cpan.org/~xdr/perlcritic-checker-1.2.6/>, for some of
132       the ideas here such as emergency_comment_prefix.
133

SUPPORT

135       Bugs may be submitted at
136       <https://github.com/houseabsolute/perl-code-tidyall/issues>.
137

SOURCE

139       The source code repository for Code-TidyAll can be found at
140       <https://github.com/houseabsolute/perl-code-tidyall>.
141

AUTHORS

143       •   Jonathan Swartz <swartz@pobox.com>
144
145       •   Dave Rolsky <autarch@urth.org>
146
148       This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
149
150       This is free software; you can redistribute it and/or modify it under
151       the same terms as the Perl 5 programming language system itself.
152
153       The full text of the license can be found in the LICENSE file included
154       with this distribution.
155
156
157
158perl v5.38.0                      2023-07-20  Code::TidyAll::SVN::Precommit(3)
Impressum