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

NAME

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

VERSION

10       version 0.74
11

SYNOPSIS

13         In .git/hooks/pre-commit:
14
15           #!/usr/bin/env perl
16           use strict;
17           use warnings;
18
19           use Code::TidyAll::Git::Precommit;
20           Code::TidyAll::Git::Precommit->check();
21

DESCRIPTION

23       This module implements a Git pre-commit hook <http://git-
24       scm.com/book/en/Customizing-Git-Git-Hooks> that checks if all files are
25       tidied and valid according to tidyall, and rejects the commit if not.
26       Files/commits are never modified by this hook.
27
28       See also Code::TidyAll::Git::Prereceive, which validates pushes to a
29       shared repo.
30

METHODS

32       This class provides one method:
33
34   Code::TidyAll::Git::Precommit->check(%params)
35       Checks that all files being added or modified in this commit are tidied
36       and valid according to tidyall. If not, then the entire commit is
37       rejected and the reason(s) are output to the client. e.g.
38
39           % git commit -m "fixups" CHI.pm CHI/Driver.pm
40           2 files did not pass tidyall check
41           lib/CHI.pm: *** 'PerlTidy': needs tidying
42           lib/CHI/Driver.pm: *** 'PerlCritic': Code before strictures are enabled
43             at /tmp/Code-TidyAll-0e6K/Driver.pm line 2
44             [TestingAndDebugging::RequireUseStrict]
45
46       In an emergency the hook can be bypassed by passing --no-verify to
47       commit:
48
49           % git commit --no-verify ...
50
51       or you can just move ".git/hooks/pre-commit" out of the way
52       temporarily.
53
54       The configuration file ("tidyall.ini" or ".tidyallrc") must be checked
55       into git in the repo root directory i.e. next to the .git directory.
56
57       By default, the hook will stash any changes not in the index
58       beforehand, and restore them afterwards, via
59
60           git stash save --keep-index --include-untracked
61           ....
62           git stash pop
63
64       This means that if the configuration file has uncommitted changes that
65       are not in the index, they will not affect the tidyall run.
66
67       This class passes mode = "commit" by default to tidyall; see modes.
68
69       Key/value parameters:
70
71       ·   conf_name
72
73           A conf file name to search for instead of the defaults.
74
75       ·   git_path
76
77           Path to git to use in commands, e.g. '/usr/bin/git' or
78           '/usr/local/bin/git'. By default, it just uses 'git', which will
79           search the user's "PATH".
80
81       ·   no_stash
82
83           Don't attempt to stash changes not in the index. This means the
84           hook will process files that are not going to be committed.
85
86       ·   tidyall_class
87
88           Subclass to use instead of Code::TidyAll.
89
90       ·   tidyall_options
91
92           A hashref of options to pass to the Code::TidyAll constructor.
93

USING AND (NOT) ENFORCING THIS HOOK

95       This hook must be placed manually in each copy of the repo - there is
96       no way to automatically distribute or enforce it. However, you can make
97       things easier on yourself or your developers as follows:
98
99       ·   Create a directory called "git/hooks" at the top of your repo (note
100           no dot prefix).
101
102               mkdir -p git/hooks
103
104       ·   Commit your pre-commit script in "git/hooks/pre-commit" containing:
105
106               #!/usr/bin/env perl
107
108               use strict;
109               use warnings;
110
111               use Code::TidyAll::Git::Precommit;
112               Code::TidyAll::Git::Precommit->check();
113
114       ·   Add a setup script in "git/setup.sh" containing
115
116               #!/bin/bash
117               chmod +x git/hooks/pre-commit
118               cd .git/hooks
119               ln -s ../../git/hooks/pre-commit
120
121       ·   Run "git/setup.sh" (or tell your developers to run it) once for
122           each new clone of the repo
123
124       See this Stack Overflow question for more information on pre-commit
125       hooks and the impossibility of enforcing their use.
126
127       See also Code::TidyAll::Git::Prereceive, which enforces tidyall on
128       pushes to a remote shared repository.
129

SUPPORT

131       Bugs may be submitted at
132       <https://github.com/houseabsolute/perl-code-tidyall/issues>.
133
134       I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".
135

SOURCE

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

AUTHORS

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