| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::GitHooks::Test; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 12 |  |  | 12 |  | 6894 | use strict; | 
|  | 12 |  |  |  |  | 23 |  | 
|  | 12 |  |  |  |  | 386 |  | 
| 4 | 12 |  |  | 12 |  | 64 | use warnings; | 
|  | 12 |  |  |  |  | 21 |  | 
|  | 12 |  |  |  |  | 471 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | # Parent class. | 
| 7 | 12 |  |  | 12 |  | 58 | use base 'Exporter'; | 
|  | 12 |  |  |  |  | 19 |  | 
|  | 12 |  |  |  |  | 1155 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | # External dependencies. | 
| 10 | 12 |  |  | 12 |  | 6908 | use Capture::Tiny; | 
|  | 12 |  |  |  |  | 171313 |  | 
|  | 12 |  |  |  |  | 665 |  | 
| 11 | 12 |  |  | 12 |  | 82 | use Carp; | 
|  | 12 |  |  |  |  | 19 |  | 
|  | 12 |  |  |  |  | 691 |  | 
| 12 | 12 |  |  | 12 |  | 83 | use Cwd; | 
|  | 12 |  |  |  |  | 25 |  | 
|  | 12 |  |  |  |  | 732 |  | 
| 13 | 12 |  |  | 12 |  | 5912 | use Data::Section -setup; | 
|  | 12 |  |  |  |  | 230376 |  | 
|  | 12 |  |  |  |  | 97 |  | 
| 14 | 12 |  |  | 12 |  | 8215 | use Data::Validate::Type; | 
|  | 12 |  |  |  |  | 24340 |  | 
|  | 12 |  |  |  |  | 612 |  | 
| 15 | 12 |  |  | 12 |  | 72 | use File::Spec; | 
|  | 12 |  |  |  |  | 12 |  | 
|  | 12 |  |  |  |  | 251 |  | 
| 16 | 12 |  |  | 12 |  | 45 | use File::Temp; | 
|  | 12 |  |  |  |  | 17 |  | 
|  | 12 |  |  |  |  | 822 |  | 
| 17 | 12 |  |  | 12 |  | 3091 | use Path::Tiny qw(); | 
|  | 12 |  |  |  |  | 34706 |  | 
|  | 12 |  |  |  |  | 231 |  | 
| 18 | 12 |  |  | 12 |  | 6123 | use Test::Exception; | 
|  | 12 |  |  |  |  | 141066 |  | 
|  | 12 |  |  |  |  | 46 |  | 
| 19 | 12 |  |  | 12 |  | 9162 | use Test::Git; | 
|  | 12 |  |  |  |  | 149857 |  | 
|  | 12 |  |  |  |  | 695 |  | 
| 20 | 12 |  |  | 12 |  | 6065 | use Test::Requires::Git -nocheck; | 
|  | 12 |  |  |  |  | 24740 |  | 
|  | 12 |  |  |  |  | 93 |  | 
| 21 | 12 |  |  | 12 |  | 7921 | use Test::More; | 
|  | 12 |  |  |  |  | 50132 |  | 
|  | 12 |  |  |  |  | 105 |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | # Internal dependencies. | 
| 24 | 12 |  |  | 12 |  | 2937 | use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES ); | 
|  | 12 |  |  |  |  | 20 |  | 
|  | 12 |  |  |  |  | 20786 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | ## no critic (RegularExpressions::RequireExtendedFormatting) | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head1 NAME | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | App::GitHooks::Test - Shared test functions for App::GitHooks. | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | =head1 VERSION | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | Version 1.9.0 | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =cut | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | our $VERSION = '1.9.0'; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | our @EXPORT_OK = qw( | 
| 43 |  |  |  |  |  |  | ok_add_file | 
| 44 |  |  |  |  |  |  | ok_add_files | 
| 45 |  |  |  |  |  |  | ok_setup_repository | 
| 46 |  |  |  |  |  |  | ); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head2 ok_add_file() | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | Create a file and add it to the git index. | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | ok_add_file( | 
| 56 |  |  |  |  |  |  | repository => $repository, | 
| 57 |  |  |  |  |  |  | path       => $path, | 
| 58 |  |  |  |  |  |  | content    => $content, | 
| 59 |  |  |  |  |  |  | ); | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Arguments: | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =over 4 | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =item * repository I<(mandatory)> | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | A C<Git::Repository> object. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =item * path I<(mandatory)> | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | The path of the file to write, relative to the root of the git repository | 
| 72 |  |  |  |  |  |  | passed. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =item * content I<(optional)> | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | The content of the file to write. | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =back | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =cut | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | sub ok_add_file | 
| 83 |  |  |  |  |  |  | { | 
| 84 | 9 |  |  | 9 | 1 | 143 | my ( %args ) = @_; | 
| 85 | 9 |  |  |  |  | 24 | my $repository = delete( $args{'repository'} ); | 
| 86 | 9 |  |  |  |  | 25 | my $path = delete( $args{'path'} ); | 
| 87 | 9 |  |  |  |  | 26 | my $content = delete( $args{'content'} ); | 
| 88 | 9 | 50 |  |  |  | 47 | croak 'Invalid argument(s): ' . join( ', ', keys %args ) | 
| 89 |  |  |  |  |  |  | if scalar( keys %args ) != 0; | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | return | 
| 92 |  |  |  |  |  |  | subtest( | 
| 93 |  |  |  |  |  |  | "Add file >$path<.", | 
| 94 |  |  |  |  |  |  | sub | 
| 95 |  |  |  |  |  |  | { | 
| 96 | 9 |  |  | 9 |  | 6134 | plan( tests => 2 ); | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | lives_ok( | 
| 99 |  |  |  |  |  |  | sub | 
| 100 |  |  |  |  |  |  | { | 
| 101 | 9 |  |  |  |  | 365 | Path::Tiny::path( $repository->work_tree(), $path ) | 
| 102 |  |  |  |  |  |  | ->spew( $content ); | 
| 103 |  |  |  |  |  |  | }, | 
| 104 | 9 |  |  |  |  | 2072 | 'Write file.', | 
| 105 |  |  |  |  |  |  | ); | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | lives_ok( | 
| 108 |  |  |  |  |  |  | sub | 
| 109 |  |  |  |  |  |  | { | 
| 110 | 9 |  |  |  |  | 467 | $repository->run( 'add', $path ); | 
| 111 |  |  |  |  |  |  | }, | 
| 112 | 9 |  |  |  |  | 11212 | 'Add the file to the git index.', | 
| 113 |  |  |  |  |  |  | ); | 
| 114 |  |  |  |  |  |  | } | 
| 115 | 9 |  |  |  |  | 105 | ); | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =head2 ok_add_files() | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | Create files and add them to the git index. | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | ok_add_files( | 
| 124 |  |  |  |  |  |  | repository => $repository, | 
| 125 |  |  |  |  |  |  | files      => | 
| 126 |  |  |  |  |  |  | { | 
| 127 |  |  |  |  |  |  | $file_name => $file_content, | 
| 128 |  |  |  |  |  |  | ... | 
| 129 |  |  |  |  |  |  | }, | 
| 130 |  |  |  |  |  |  | ); | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | Arguments: | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =over 4 | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =item * repository I<(mandatory)> | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | A C<Git::Repository> object. | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =item * files I<(optional)> | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | A hashref with file names as keys and the content of each file as the | 
| 143 |  |  |  |  |  |  | corresponding value. | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =back | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =cut | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | sub ok_add_files | 
| 150 |  |  |  |  |  |  | { | 
| 151 | 0 |  |  | 0 | 1 | 0 | my ( %args ) = @_; | 
| 152 | 0 |  |  |  |  | 0 | my $repository = delete( $args{'repository'} ); | 
| 153 | 0 |  | 0 |  |  | 0 | my $files = delete( $args{'files'} ) // {}; | 
| 154 | 0 | 0 |  |  |  | 0 | croak 'Unknown argument(s): ' . join( ', ', keys %args ) | 
| 155 |  |  |  |  |  |  | if scalar( keys %args ) != 0; | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | return | 
| 158 |  |  |  |  |  |  | subtest( | 
| 159 |  |  |  |  |  |  | 'Set up test files.', | 
| 160 |  |  |  |  |  |  | sub | 
| 161 |  |  |  |  |  |  | { | 
| 162 | 0 |  |  | 0 |  | 0 | plan( tests => scalar( keys %$files ) ); | 
| 163 |  |  |  |  |  |  |  | 
| 164 | 0 |  |  |  |  | 0 | foreach my $filename ( keys %$files ) | 
| 165 |  |  |  |  |  |  | { | 
| 166 |  |  |  |  |  |  | ok_add_file( | 
| 167 |  |  |  |  |  |  | repository => $repository, | 
| 168 |  |  |  |  |  |  | path       => $filename, | 
| 169 | 0 |  |  |  |  | 0 | content    => $files->{ $filename }, | 
| 170 |  |  |  |  |  |  | ); | 
| 171 |  |  |  |  |  |  | } | 
| 172 |  |  |  |  |  |  | } | 
| 173 | 0 |  |  |  |  | 0 | ); | 
| 174 |  |  |  |  |  |  | } | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | =head2 ok_setup_repository() | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | Set up a test repository. | 
| 180 |  |  |  |  |  |  |  | 
| 181 |  |  |  |  |  |  | ok_setup_repository( | 
| 182 |  |  |  |  |  |  | cleanup_test_repository => $cleanup_test_repository, # default 1 | 
| 183 |  |  |  |  |  |  | config                  => $config,                  # default '' | 
| 184 |  |  |  |  |  |  | hooks                   => \@hooks,                  # default [] | 
| 185 |  |  |  |  |  |  | plugins                 => \@plugins,                # default [] | 
| 186 |  |  |  |  |  |  | ); | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | Arguments: | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | =over 4 | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | =item * cleanup_test_repository | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | Whether the test repository created in order to run a test should be destroyed | 
| 195 |  |  |  |  |  |  | at the end of the test (default: 1). | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | =item * config | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | Elements to add to the C<.githooksrc> file set up at the root of the test | 
| 200 |  |  |  |  |  |  | repository. | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  | =item * hooks | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | An arrayref of the names of the hooks to set up for this test (for example, | 
| 205 |  |  |  |  |  |  | C<commit-msg>). | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | =item * plugins | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | An arrayref of the module names of the plugins to run for this test (for | 
| 210 |  |  |  |  |  |  | example, C<App::GitHooks::Plugins::Test::CustomReply>). | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | =back | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  | =cut | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | sub ok_setup_repository | 
| 217 |  |  |  |  |  |  | { | 
| 218 | 9 |  |  | 9 | 1 | 80 | my ( %args ) = @_; | 
| 219 | 9 |  | 50 |  |  | 48 | my $cleanup_test_repository = delete( $args{'cleanup_test_repository'} ) // 1; | 
| 220 | 9 |  | 50 |  |  | 45 | my $config = delete( $args{'config'} ) // ''; | 
| 221 | 9 |  | 50 |  |  | 87 | my $hooks = delete( $args{'hooks'} ) // []; | 
| 222 | 9 |  | 50 |  |  | 36 | my $plugins = delete( $args{'plugins'} ) // []; | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | # Validate the parameters. | 
| 225 | 9 | 50 |  |  |  | 78 | croak "The 'plugins' argument must be an arrayref" | 
| 226 |  |  |  |  |  |  | if !Data::Validate::Type::is_arrayref( $plugins ); | 
| 227 | 9 | 50 |  |  |  | 249 | croak "The 'hooks' argument must be an arrayref" | 
| 228 |  |  |  |  |  |  | if !Data::Validate::Type::is_arrayref( $hooks ); | 
| 229 | 9 | 50 |  |  |  | 132 | croak 'Unknown argument(s): ' . join( ', ', keys %args ) | 
| 230 |  |  |  |  |  |  | if scalar( keys %args ) != 0; | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | # Check if we need to propagate test coverage checks to the hooks. | 
| 233 |  |  |  |  |  |  | my $test_coverage = ( ( $ENV{'HARNESS_PERL_SWITCHES'} // '' ) =~ /Devel::Cover/ ) | 
| 234 | 9 | 50 | 33 |  |  | 112 | || ( ( $ENV{'PERL5OPT'} // '' ) =~ /Devel::Cover/ ) | 
| 235 |  |  |  |  |  |  | ? 1 | 
| 236 |  |  |  |  |  |  | : 0; | 
| 237 |  |  |  |  |  |  |  | 
| 238 | 9 |  |  |  |  | 18 | my $repository; | 
| 239 |  |  |  |  |  |  | subtest( | 
| 240 |  |  |  |  |  |  | 'Set up temporary test repository.', | 
| 241 |  |  |  |  |  |  | sub | 
| 242 |  |  |  |  |  |  | { | 
| 243 | 9 |  |  | 9 |  | 3544 | plan( tests => 10 + scalar( @$hooks ) ); | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | # Create a temporary repository. | 
| 246 | 9 |  |  |  |  | 944 | ok( | 
| 247 |  |  |  |  |  |  | defined( | 
| 248 |  |  |  |  |  |  | $repository = Test::Git::test_repository( | 
| 249 |  |  |  |  |  |  | temp => [ CLEANUP => $cleanup_test_repository ], | 
| 250 |  |  |  |  |  |  | ) | 
| 251 |  |  |  |  |  |  | ), | 
| 252 |  |  |  |  |  |  | 'Create the test repository.', | 
| 253 |  |  |  |  |  |  | ); | 
| 254 | 9 |  |  |  |  | 887903 | note( 'Using test repository ' . $repository->work_tree() ); | 
| 255 |  |  |  |  |  |  |  | 
| 256 |  |  |  |  |  |  | lives_ok( | 
| 257 |  |  |  |  |  |  | sub | 
| 258 |  |  |  |  |  |  | { | 
| 259 | 9 |  |  |  |  | 413 | $repository->run( 'config', 'user.email', 'author1@example.com' ); | 
| 260 |  |  |  |  |  |  | }, | 
| 261 | 9 |  |  |  |  | 1999 | 'Set the test author\'s email.', | 
| 262 |  |  |  |  |  |  | ); | 
| 263 |  |  |  |  |  |  |  | 
| 264 |  |  |  |  |  |  | lives_ok( | 
| 265 |  |  |  |  |  |  | sub | 
| 266 |  |  |  |  |  |  | { | 
| 267 | 9 |  |  |  |  | 334 | $repository->run( 'config', 'user.name', 'Test Author' ); | 
| 268 |  |  |  |  |  |  | }, | 
| 269 | 9 |  |  |  |  | 174377 | 'Set the test author\'s name.', | 
| 270 |  |  |  |  |  |  | ); | 
| 271 |  |  |  |  |  |  |  | 
| 272 |  |  |  |  |  |  | # Make sure we have a hook template available. | 
| 273 | 9 | 50 |  |  |  | 122277 | my $hook_template_ref = __PACKAGE__->section_data( | 
| 274 |  |  |  |  |  |  | $test_coverage | 
| 275 |  |  |  |  |  |  | ? 'devel_cover' | 
| 276 |  |  |  |  |  |  | : 'default' | 
| 277 |  |  |  |  |  |  | ); | 
| 278 | 9 | 50 |  |  |  | 6659 | my $hook_template = defined( $hook_template_ref ) | 
| 279 |  |  |  |  |  |  | ? $$hook_template_ref | 
| 280 |  |  |  |  |  |  | : undef; | 
| 281 | 9 | 50 | 33 |  |  | 216 | ok( | 
| 282 |  |  |  |  |  |  | defined( $hook_template ) | 
| 283 |  |  |  |  |  |  | && ( $hook_template =~ /\w/ ), | 
| 284 |  |  |  |  |  |  | 'The hook template exists.', | 
| 285 |  |  |  |  |  |  | ) || diag( explain( $hook_template_ref ) ); | 
| 286 |  |  |  |  |  |  |  | 
| 287 |  |  |  |  |  |  | # The hooks are perl processes instantiated by git, so they will not have the | 
| 288 |  |  |  |  |  |  | # same @INC necessarily, which is a problem for testing in particular when | 
| 289 |  |  |  |  |  |  | # specific libs are included on the command line of the test. To that effect, | 
| 290 |  |  |  |  |  |  | # we hardcode the current @INC into the hook startup files. | 
| 291 |  |  |  |  |  |  | my $libs = join( | 
| 292 |  |  |  |  |  |  | ' ', | 
| 293 | 9 |  |  |  |  | 3506 | map { File::Spec->rel2abs( $_ ) } @INC | 
|  | 108 |  |  |  |  | 1208 |  | 
| 294 |  |  |  |  |  |  | ); | 
| 295 | 9 |  |  |  |  | 114 | $hook_template =~ s/\Q{libs}\E/$libs/g; | 
| 296 |  |  |  |  |  |  |  | 
| 297 |  |  |  |  |  |  | # Template replacements. | 
| 298 | 9 |  |  |  |  | 119 | $hook_template =~ s/\Q{interpreter_path}\E/$^X/g; | 
| 299 |  |  |  |  |  |  |  | 
| 300 |  |  |  |  |  |  | # Specific actions for when test coverage is enabled. | 
| 301 | 9 |  |  |  |  | 20 | my $cover_db_path; | 
| 302 |  |  |  |  |  |  | SKIP: | 
| 303 |  |  |  |  |  |  | { | 
| 304 | 9 | 50 |  |  |  | 15 | skip( | 
|  | 9 |  |  |  |  | 32 |  | 
| 305 |  |  |  |  |  |  | 'Test coverage not enabled.', | 
| 306 |  |  |  |  |  |  | 5, | 
| 307 |  |  |  |  |  |  | ) if !$test_coverage; | 
| 308 |  |  |  |  |  |  |  | 
| 309 |  |  |  |  |  |  | # Find out in which directory the coverage database should be stored. | 
| 310 |  |  |  |  |  |  | SKIP: | 
| 311 |  |  |  |  |  |  | { | 
| 312 | 9 |  |  |  |  | 11 | skip( | 
| 313 |  |  |  |  |  |  | 'The COVER_DB_PATH environment variable is not set.', | 
| 314 |  |  |  |  |  |  | 1, | 
| 315 | 9 | 50 | 50 |  |  | 155 | ) if ( $ENV{'COVER_DB_PATH'} // '' ) eq ''; | 
| 316 |  |  |  |  |  |  |  | 
| 317 |  |  |  |  |  |  | my $is_valid = | 
| 318 |  |  |  |  |  |  | ok( | 
| 319 | 0 |  |  |  |  | 0 | -e $ENV{'COVER_DB_PATH'}, | 
| 320 |  |  |  |  |  |  | 'The coverage database directory specified in the COVER_DB_PATH environment variable is valid.', | 
| 321 |  |  |  |  |  |  | ); | 
| 322 |  |  |  |  |  |  |  | 
| 323 | 0 | 0 |  |  |  | 0 | $cover_db_path = $ENV{'COVER_DB_PATH'} | 
| 324 |  |  |  |  |  |  | if $is_valid; | 
| 325 |  |  |  |  |  |  | }; | 
| 326 |  |  |  |  |  |  |  | 
| 327 |  |  |  |  |  |  | # Use File::Spec->catfile() for portability. | 
| 328 | 9 |  | 33 |  |  | 2208 | ok( | 
| 329 |  |  |  |  |  |  | defined( | 
| 330 |  |  |  |  |  |  | $cover_db_path //= File::Spec->catfile( Cwd::getcwd(), 'cover_db' ) | 
| 331 |  |  |  |  |  |  | ), | 
| 332 |  |  |  |  |  |  | 'The coverage database directory is set.', | 
| 333 |  |  |  |  |  |  | ); | 
| 334 | 9 |  |  |  |  | 2988 | note( "Using the coverage database directory >$cover_db_path<." ); | 
| 335 | 9 | 50 |  |  |  | 1483 | $hook_template =~ s/\Q{cover_db_path}\E/$cover_db_path/g | 
| 336 |  |  |  |  |  |  | if defined( $cover_db_path ); | 
| 337 |  |  |  |  |  |  |  | 
| 338 |  |  |  |  |  |  | # Note: this is required because Devel::Coverage only analyzes the coverage | 
| 339 |  |  |  |  |  |  | # for files in -dir, which defaults to the current directory. It can be changed | 
| 340 |  |  |  |  |  |  | # to '/home' or '/' to make it cover both the test repository and the main lib/ | 
| 341 |  |  |  |  |  |  | # directory in which the code for the hooks lives, but this wouldn't be portable. | 
| 342 |  |  |  |  |  |  | # Instead, we symlink the lib directory into the test repository, and the | 
| 343 |  |  |  |  |  |  | # coverage-specific version of the test githook template will use that symlink as | 
| 344 |  |  |  |  |  |  | # the source for the App::GitHooks modules. As long as the target system supports | 
| 345 |  |  |  |  |  |  | # symlinks, it then allows for coverage testing. | 
| 346 |  |  |  |  |  |  | # Note: lib/ is necessary for testing coverage via 'prove', but | 
| 347 |  |  |  |  |  |  | # blib/lib/ is necessary for testing coverage via 'cover'. | 
| 348 | 9 |  |  |  |  | 183 | ok( | 
| 349 |  |  |  |  |  |  | symlink( Cwd::getcwd() . '/lib', $repository->work_tree() . '/lib' ), | 
| 350 |  |  |  |  |  |  | 'Symlink lib/ into the test repository to allow proper merging of coverage databases (with "prove").', | 
| 351 |  |  |  |  |  |  | ); | 
| 352 | 9 |  |  |  |  | 3778 | ok( | 
| 353 |  |  |  |  |  |  | mkdir( $repository->work_tree() . '/blib' ), | 
| 354 |  |  |  |  |  |  | 'Create a blib/ directory in the test repository.', | 
| 355 |  |  |  |  |  |  | ); | 
| 356 | 9 |  |  |  |  | 3622 | ok( | 
| 357 |  |  |  |  |  |  | symlink( Cwd::getcwd() . '/lib', $repository->work_tree() . '/blib/lib' ), | 
| 358 |  |  |  |  |  |  | 'Symlink blib/lib/ into the test repository to allow proper merging of coverage databases (with "cover").', | 
| 359 |  |  |  |  |  |  | ); | 
| 360 |  |  |  |  |  |  | }; | 
| 361 |  |  |  |  |  |  |  | 
| 362 |  |  |  |  |  |  | # Set up the hooks. | 
| 363 | 9 |  |  |  |  | 3469 | foreach my $hook_name ( @$hooks ) | 
| 364 |  |  |  |  |  |  | { | 
| 365 |  |  |  |  |  |  | subtest( | 
| 366 |  |  |  |  |  |  | "Set up the $hook_name hook.", | 
| 367 |  |  |  |  |  |  | sub | 
| 368 |  |  |  |  |  |  | { | 
| 369 | 9 |  |  |  |  | 6059 | plan( tests => 2 ); | 
| 370 |  |  |  |  |  |  |  | 
| 371 | 9 |  |  |  |  | 2091 | my $hook_path = $repository->work_tree() . '/.git/hooks/' . $hook_name; | 
| 372 |  |  |  |  |  |  | lives_ok( | 
| 373 |  |  |  |  |  |  | sub | 
| 374 |  |  |  |  |  |  | { | 
| 375 | 9 |  |  |  |  | 402 | Path::Tiny::path( $hook_path ) | 
| 376 |  |  |  |  |  |  | ->spew( $hook_template ); | 
| 377 |  |  |  |  |  |  | }, | 
| 378 | 9 |  |  |  |  | 127 | 'Write the hook.', | 
| 379 |  |  |  |  |  |  | ); | 
| 380 |  |  |  |  |  |  |  | 
| 381 | 9 |  |  |  |  | 8853 | ok( | 
| 382 |  |  |  |  |  |  | chmod( 0755, $hook_path ), | 
| 383 |  |  |  |  |  |  | "Make the $hook_name hook executable.", | 
| 384 |  |  |  |  |  |  | ); | 
| 385 |  |  |  |  |  |  | } | 
| 386 | 9 |  |  |  |  | 223 | ); | 
| 387 |  |  |  |  |  |  | } | 
| 388 |  |  |  |  |  |  |  | 
| 389 |  |  |  |  |  |  | # Set up a .githooksrc config. | 
| 390 |  |  |  |  |  |  | lives_ok( | 
| 391 |  |  |  |  |  |  | sub | 
| 392 |  |  |  |  |  |  | { | 
| 393 | 9 |  |  |  |  | 208 | my $content = ""; | 
| 394 |  |  |  |  |  |  |  | 
| 395 |  |  |  |  |  |  | # Main section. | 
| 396 |  |  |  |  |  |  | { | 
| 397 |  |  |  |  |  |  | # Only run specific plugins. | 
| 398 | 9 | 50 |  |  |  | 72 | $content .= "force_plugins = " . join( ', ', @$plugins ) . "\n" | 
| 399 |  |  |  |  |  |  | if defined( $plugins ); | 
| 400 |  |  |  |  |  |  | } | 
| 401 |  |  |  |  |  |  |  | 
| 402 |  |  |  |  |  |  | # Testing section. | 
| 403 |  |  |  |  |  |  | { | 
| 404 | 9 |  |  |  |  | 15 | $content .= "[testing]\n"; | 
|  | 9 |  |  |  |  | 17 |  | 
|  | 9 |  |  |  |  | 19 |  | 
| 405 |  |  |  |  |  |  |  | 
| 406 |  |  |  |  |  |  | # Pretend we're in an interactive terminal even if we're doing automated testing. | 
| 407 | 9 |  |  |  |  | 20 | $content .= "force_interactive = 1\n"; | 
| 408 |  |  |  |  |  |  |  | 
| 409 |  |  |  |  |  |  | # Disable color, to make it easier to match output. | 
| 410 | 9 |  |  |  |  | 20 | $content .= "force_use_colors = 0\n"; | 
| 411 |  |  |  |  |  |  |  | 
| 412 |  |  |  |  |  |  | # Disable utf-8 characters, to make it easier to match output. | 
| 413 | 9 |  |  |  |  | 18 | $content .= "force_is_utf8 = 0\n"; | 
| 414 |  |  |  |  |  |  |  | 
| 415 |  |  |  |  |  |  | # Just have commit-msg exit with the result of the checks, instead | 
| 416 |  |  |  |  |  |  | # of forcing to correct the issue. | 
| 417 | 9 |  |  |  |  | 15 | $content .= "commit_msg_no_edit = 1\n"; | 
| 418 |  |  |  |  |  |  | } | 
| 419 |  |  |  |  |  |  |  | 
| 420 |  |  |  |  |  |  | # Add any custom config passed. | 
| 421 | 9 |  |  |  |  | 23 | $content .= $config; | 
| 422 |  |  |  |  |  |  |  | 
| 423 |  |  |  |  |  |  | # Write the file. | 
| 424 | 9 |  |  |  |  | 38 | Path::Tiny::path( $repository->work_tree(), '.githooksrc' ) | 
| 425 |  |  |  |  |  |  | ->spew( $content ); | 
| 426 |  |  |  |  |  |  | }, | 
| 427 | 9 |  |  |  |  | 8351 | 'Write a .githooksrc config file.', | 
| 428 |  |  |  |  |  |  | ); | 
| 429 |  |  |  |  |  |  | } | 
| 430 | 9 |  |  |  |  | 128 | ); | 
| 431 |  |  |  |  |  |  |  | 
| 432 | 9 |  |  |  |  | 12702 | return $repository; | 
| 433 |  |  |  |  |  |  | } | 
| 434 |  |  |  |  |  |  |  | 
| 435 |  |  |  |  |  |  |  | 
| 436 |  |  |  |  |  |  | =head2 ok_reset_githooksrc() | 
| 437 |  |  |  |  |  |  |  | 
| 438 |  |  |  |  |  |  | Ensures that an empty C<.githooksrc> is used. | 
| 439 |  |  |  |  |  |  |  | 
| 440 |  |  |  |  |  |  | ok_reset_githooksrc(); | 
| 441 |  |  |  |  |  |  |  | 
| 442 |  |  |  |  |  |  | Arguments: | 
| 443 |  |  |  |  |  |  |  | 
| 444 |  |  |  |  |  |  | =over 4 | 
| 445 |  |  |  |  |  |  |  | 
| 446 |  |  |  |  |  |  | =item * content I<(optional)> | 
| 447 |  |  |  |  |  |  |  | 
| 448 |  |  |  |  |  |  | Content for the C<.githooksrc> file. | 
| 449 |  |  |  |  |  |  |  | 
| 450 |  |  |  |  |  |  | By default, this function generates an empty C<.githooksrc> file, which has the | 
| 451 |  |  |  |  |  |  | effect of using the defaults of L<App::GitHooks>. | 
| 452 |  |  |  |  |  |  |  | 
| 453 |  |  |  |  |  |  | =back | 
| 454 |  |  |  |  |  |  |  | 
| 455 |  |  |  |  |  |  | =cut | 
| 456 |  |  |  |  |  |  |  | 
| 457 |  |  |  |  |  |  | sub ok_reset_githooksrc | 
| 458 |  |  |  |  |  |  | { | 
| 459 | 25 |  |  | 25 | 1 | 534731 | my ( %args ) = @_; | 
| 460 | 25 |  | 100 |  |  | 172 | my $content = delete( $args{'content'} ) // ''; | 
| 461 |  |  |  |  |  |  |  | 
| 462 | 25 | 50 |  |  |  | 163 | croak 'Invalid argument(s): ' . join( ', ', keys %args ) | 
| 463 |  |  |  |  |  |  | if scalar( keys %args ) != 0; | 
| 464 |  |  |  |  |  |  |  | 
| 465 |  |  |  |  |  |  | subtest( | 
| 466 |  |  |  |  |  |  | 'Set up .githooksrc file.', | 
| 467 |  |  |  |  |  |  | sub | 
| 468 |  |  |  |  |  |  | { | 
| 469 | 25 |  |  | 25 |  | 14943 | plan( tests => 4 ); | 
| 470 |  |  |  |  |  |  |  | 
| 471 | 25 |  |  |  |  | 4167 | ok( | 
| 472 |  |  |  |  |  |  | my ( $file_handle, $filename ) = File::Temp::tempfile(), | 
| 473 |  |  |  |  |  |  | 'Create a temporary file to store the githooks config.', | 
| 474 |  |  |  |  |  |  | ); | 
| 475 |  |  |  |  |  |  |  | 
| 476 | 25 |  |  |  |  | 126581 | ok( | 
| 477 |  |  |  |  |  |  | ( print $file_handle $content ), | 
| 478 |  |  |  |  |  |  | 'Write the githooks config.', | 
| 479 |  |  |  |  |  |  | ); | 
| 480 |  |  |  |  |  |  |  | 
| 481 | 25 |  |  |  |  | 9916 | ok( | 
| 482 |  |  |  |  |  |  | close( $file_handle ), | 
| 483 |  |  |  |  |  |  | 'Close githooks config.', | 
| 484 |  |  |  |  |  |  | ); | 
| 485 |  |  |  |  |  |  |  | 
| 486 | 25 |  |  |  |  | 8740 | note( "GITHOOKSRC_FORCE will be set to $filename." ); | 
| 487 |  |  |  |  |  |  |  | 
| 488 |  |  |  |  |  |  | # Note: we need to make a global change to %ENV here, so that it | 
| 489 |  |  |  |  |  |  | # propagates to the caller's scope. | 
| 490 |  |  |  |  |  |  | ok( | 
| 491 | 25 |  |  |  |  | 4061 | $ENV{'GITHOOKSRC_FORCE'} = $filename, ## no critic (Variables::RequireLocalizedPunctuationVars) | 
| 492 |  |  |  |  |  |  | 'Set the environment variable GITHOOKSRC_FORCE to point to the new config.', | 
| 493 |  |  |  |  |  |  | ); | 
| 494 |  |  |  |  |  |  | } | 
| 495 | 25 |  |  |  |  | 333 | ); | 
| 496 |  |  |  |  |  |  |  | 
| 497 | 25 |  |  |  |  | 22236 | return; | 
| 498 |  |  |  |  |  |  | } | 
| 499 |  |  |  |  |  |  |  | 
| 500 |  |  |  |  |  |  |  | 
| 501 |  |  |  |  |  |  | =head2 test_hook() | 
| 502 |  |  |  |  |  |  |  | 
| 503 |  |  |  |  |  |  | Test a git hook. | 
| 504 |  |  |  |  |  |  |  | 
| 505 |  |  |  |  |  |  | App::GitHooks::Test::test_hook( | 
| 506 |  |  |  |  |  |  | tests                   => \@tests, | 
| 507 |  |  |  |  |  |  | hook_name               => $hook_name, | 
| 508 |  |  |  |  |  |  | plugins                 => \@plugins, | 
| 509 |  |  |  |  |  |  | cleanup_test_repository => $cleanup_test_repository, # default 1 | 
| 510 |  |  |  |  |  |  | ); | 
| 511 |  |  |  |  |  |  |  | 
| 512 |  |  |  |  |  |  | Mandatory arguments: | 
| 513 |  |  |  |  |  |  |  | 
| 514 |  |  |  |  |  |  | =over 4 | 
| 515 |  |  |  |  |  |  |  | 
| 516 |  |  |  |  |  |  | =item * tests | 
| 517 |  |  |  |  |  |  |  | 
| 518 |  |  |  |  |  |  | A set of tests to run. | 
| 519 |  |  |  |  |  |  |  | 
| 520 |  |  |  |  |  |  | # TODO: document tests format. | 
| 521 |  |  |  |  |  |  |  | 
| 522 |  |  |  |  |  |  | =item * hook_name | 
| 523 |  |  |  |  |  |  |  | 
| 524 |  |  |  |  |  |  | The name of the git hook to test (for example, C<commit-msg>). | 
| 525 |  |  |  |  |  |  |  | 
| 526 |  |  |  |  |  |  | =item * plugins | 
| 527 |  |  |  |  |  |  |  | 
| 528 |  |  |  |  |  |  | An arrayref of the module names of the plugins to run for this test (for | 
| 529 |  |  |  |  |  |  | example, C<App::GitHooks::Plugins::Test::CustomReply>). | 
| 530 |  |  |  |  |  |  |  | 
| 531 |  |  |  |  |  |  | =back | 
| 532 |  |  |  |  |  |  |  | 
| 533 |  |  |  |  |  |  | Optional arguments: | 
| 534 |  |  |  |  |  |  |  | 
| 535 |  |  |  |  |  |  | =over 4 | 
| 536 |  |  |  |  |  |  |  | 
| 537 |  |  |  |  |  |  | =item * cleanup_test_repository | 
| 538 |  |  |  |  |  |  |  | 
| 539 |  |  |  |  |  |  | Whether the test repository created in order to run a test should be destroyed | 
| 540 |  |  |  |  |  |  | at the end of the test (default: 1). | 
| 541 |  |  |  |  |  |  |  | 
| 542 |  |  |  |  |  |  | =back | 
| 543 |  |  |  |  |  |  |  | 
| 544 |  |  |  |  |  |  | =cut | 
| 545 |  |  |  |  |  |  |  | 
| 546 |  |  |  |  |  |  | sub test_hook | 
| 547 |  |  |  |  |  |  | { | 
| 548 | 3 |  |  | 3 | 1 | 99 | my ( %args ) = @_; | 
| 549 | 3 |  |  |  |  | 8 | my $tests = delete( $args{'tests'} ); | 
| 550 | 3 |  |  |  |  | 7 | my $hook_name = delete( $args{'hook_name'} ); | 
| 551 | 3 |  |  |  |  | 7 | my $plugins = delete( $args{'plugins'} ); | 
| 552 | 3 |  | 50 |  |  | 10 | my $cleanup_test_repository = delete( $args{'cleanup_test_repository'} ) // 1; | 
| 553 | 3 | 50 |  |  |  | 14 | croak "Invalid arguments passed: " . join( ', ', keys %args ) | 
| 554 |  |  |  |  |  |  | if scalar( keys %args ) != 0; | 
| 555 | 3 | 50 |  |  |  | 12 | croak "A hook name must be specified" | 
| 556 |  |  |  |  |  |  | if !defined( $hook_name ); | 
| 557 | 3 | 50 |  |  |  | 20 | croak "The hook name is not valid" | 
| 558 |  |  |  |  |  |  | if $hook_name !~ /^[\w-]+$/; | 
| 559 |  |  |  |  |  |  |  | 
| 560 |  |  |  |  |  |  | # Bail out if Git isn't available. | 
| 561 | 3 |  |  |  |  | 16 | Test::Requires::Git::test_requires_git( '1.7.4.1' ); | 
| 562 | 3 |  |  |  |  | 15637 | plan( tests => scalar( @$tests ) ); | 
| 563 |  |  |  |  |  |  |  | 
| 564 | 3 |  |  |  |  | 1864 | foreach my $test ( @$tests ) | 
| 565 |  |  |  |  |  |  | { | 
| 566 |  |  |  |  |  |  | subtest( | 
| 567 |  |  |  |  |  |  | $test->{'name'}, | 
| 568 |  |  |  |  |  |  | sub | 
| 569 |  |  |  |  |  |  | { | 
| 570 | 9 |  |  | 9 |  | 5081 | plan( tests => 5 ); | 
| 571 |  |  |  |  |  |  |  | 
| 572 |  |  |  |  |  |  | my $repository = ok_setup_repository( | 
| 573 |  |  |  |  |  |  | cleanup_test_repository => $cleanup_test_repository, | 
| 574 | 9 |  |  |  |  | 1086 | config                  => $test->{'config'}, | 
| 575 |  |  |  |  |  |  | hooks                   => [ $hook_name ], | 
| 576 |  |  |  |  |  |  | plugins                 => $plugins, | 
| 577 |  |  |  |  |  |  | ); | 
| 578 |  |  |  |  |  |  |  | 
| 579 |  |  |  |  |  |  | # Set up a test file. | 
| 580 | 9 |  |  |  |  | 67 | ok_add_file( | 
| 581 |  |  |  |  |  |  | repository => $repository, | 
| 582 |  |  |  |  |  |  | path       => 'test.pl', | 
| 583 |  |  |  |  |  |  | content    => "#!perl\n\nuse strict;\nbareword;\n", | 
| 584 |  |  |  |  |  |  | ); | 
| 585 |  |  |  |  |  |  |  | 
| 586 |  |  |  |  |  |  | # Try to commit. | 
| 587 | 9 |  |  |  |  | 145046 | my $stderr; | 
| 588 |  |  |  |  |  |  | my $exit_status; | 
| 589 |  |  |  |  |  |  | lives_ok( | 
| 590 |  |  |  |  |  |  | sub | 
| 591 |  |  |  |  |  |  | { | 
| 592 |  |  |  |  |  |  | $stderr = Capture::Tiny::capture_stderr( | 
| 593 |  |  |  |  |  |  | sub | 
| 594 |  |  |  |  |  |  | { | 
| 595 | 9 |  |  |  |  | 8626 | $repository->run( 'commit', '-m', 'Test message.' ); | 
| 596 | 9 |  |  |  |  | 19829691 | $exit_status = $? >> 8; | 
| 597 |  |  |  |  |  |  | } | 
| 598 | 9 |  |  |  |  | 827 | ); | 
| 599 | 9 |  |  |  |  | 5125 | note( $stderr ); | 
| 600 |  |  |  |  |  |  | }, | 
| 601 | 9 |  |  |  |  | 107 | 'Commit the changes.', | 
| 602 |  |  |  |  |  |  | ); | 
| 603 |  |  |  |  |  |  |  | 
| 604 |  |  |  |  |  |  | like( | 
| 605 |  |  |  |  |  |  | $stderr, | 
| 606 | 9 |  |  |  |  | 5331 | $test->{'expected'}, | 
| 607 |  |  |  |  |  |  | "The output matches expected results.", | 
| 608 |  |  |  |  |  |  | ); | 
| 609 |  |  |  |  |  |  |  | 
| 610 |  |  |  |  |  |  | is( | 
| 611 |  |  |  |  |  |  | $exit_status, | 
| 612 | 9 |  |  |  |  | 2093 | $test->{'exit_status'}, | 
| 613 |  |  |  |  |  |  | 'The exit status is correct.', | 
| 614 |  |  |  |  |  |  | ); | 
| 615 |  |  |  |  |  |  | } | 
| 616 | 9 |  |  |  |  | 3948 | ); | 
| 617 |  |  |  |  |  |  | } | 
| 618 |  |  |  |  |  |  |  | 
| 619 | 3 |  |  |  |  | 9288 | return; | 
| 620 |  |  |  |  |  |  | } | 
| 621 |  |  |  |  |  |  |  | 
| 622 |  |  |  |  |  |  |  | 
| 623 |  |  |  |  |  |  | =head1 BUGS | 
| 624 |  |  |  |  |  |  |  | 
| 625 |  |  |  |  |  |  | Please report any bugs or feature requests through the web interface at | 
| 626 |  |  |  |  |  |  | L<https://github.com/guillaumeaubert/App-GitHooks/issues/new>. | 
| 627 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on | 
| 628 |  |  |  |  |  |  | your bug as I make changes. | 
| 629 |  |  |  |  |  |  |  | 
| 630 |  |  |  |  |  |  |  | 
| 631 |  |  |  |  |  |  | =head1 SUPPORT | 
| 632 |  |  |  |  |  |  |  | 
| 633 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 634 |  |  |  |  |  |  |  | 
| 635 |  |  |  |  |  |  | perldoc App::GitHooks::Test | 
| 636 |  |  |  |  |  |  |  | 
| 637 |  |  |  |  |  |  |  | 
| 638 |  |  |  |  |  |  | You can also look for information at: | 
| 639 |  |  |  |  |  |  |  | 
| 640 |  |  |  |  |  |  | =over | 
| 641 |  |  |  |  |  |  |  | 
| 642 |  |  |  |  |  |  | =item * GitHub's request tracker | 
| 643 |  |  |  |  |  |  |  | 
| 644 |  |  |  |  |  |  | L<https://github.com/guillaumeaubert/App-GitHooks/issues> | 
| 645 |  |  |  |  |  |  |  | 
| 646 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 647 |  |  |  |  |  |  |  | 
| 648 |  |  |  |  |  |  | L<http://annocpan.org/dist/app-githooks> | 
| 649 |  |  |  |  |  |  |  | 
| 650 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 651 |  |  |  |  |  |  |  | 
| 652 |  |  |  |  |  |  | L<http://cpanratings.perl.org/d/app-githooks> | 
| 653 |  |  |  |  |  |  |  | 
| 654 |  |  |  |  |  |  | =item * MetaCPAN | 
| 655 |  |  |  |  |  |  |  | 
| 656 |  |  |  |  |  |  | L<https://metacpan.org/release/App-GitHooks> | 
| 657 |  |  |  |  |  |  |  | 
| 658 |  |  |  |  |  |  | =back | 
| 659 |  |  |  |  |  |  |  | 
| 660 |  |  |  |  |  |  |  | 
| 661 |  |  |  |  |  |  | =head1 AUTHOR | 
| 662 |  |  |  |  |  |  |  | 
| 663 |  |  |  |  |  |  | L<Guillaume Aubert|https://metacpan.org/author/AUBERTG>, | 
| 664 |  |  |  |  |  |  | C<< <aubertg at cpan.org> >>. | 
| 665 |  |  |  |  |  |  |  | 
| 666 |  |  |  |  |  |  |  | 
| 667 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 668 |  |  |  |  |  |  |  | 
| 669 |  |  |  |  |  |  | Copyright 2013-2017 Guillaume Aubert. | 
| 670 |  |  |  |  |  |  |  | 
| 671 |  |  |  |  |  |  | This code is free software; you can redistribute it and/or modify it under the | 
| 672 |  |  |  |  |  |  | same terms as Perl 5 itself. | 
| 673 |  |  |  |  |  |  |  | 
| 674 |  |  |  |  |  |  | This program is distributed in the hope that it will be useful, but WITHOUT ANY | 
| 675 |  |  |  |  |  |  | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 
| 676 |  |  |  |  |  |  | PARTICULAR PURPOSE. See the LICENSE file for more details. | 
| 677 |  |  |  |  |  |  |  | 
| 678 |  |  |  |  |  |  | =cut | 
| 679 |  |  |  |  |  |  |  | 
| 680 |  |  |  |  |  |  | 1; | 
| 681 |  |  |  |  |  |  |  | 
| 682 |  |  |  |  |  |  |  | 
| 683 |  |  |  |  |  |  | __DATA__ | 
| 684 |  |  |  |  |  |  |  | 
| 685 |  |  |  |  |  |  | __[ default ]__ | 
| 686 |  |  |  |  |  |  | #!{interpreter_path} | 
| 687 |  |  |  |  |  |  |  | 
| 688 |  |  |  |  |  |  | use strict; | 
| 689 |  |  |  |  |  |  | use warnings; | 
| 690 |  |  |  |  |  |  |  | 
| 691 |  |  |  |  |  |  | use lib qw( {libs} ); | 
| 692 |  |  |  |  |  |  |  | 
| 693 |  |  |  |  |  |  | use App::GitHooks; | 
| 694 |  |  |  |  |  |  |  | 
| 695 |  |  |  |  |  |  |  | 
| 696 |  |  |  |  |  |  | App::GitHooks->run( | 
| 697 |  |  |  |  |  |  | name      => $0, | 
| 698 |  |  |  |  |  |  | arguments => \@ARGV, | 
| 699 |  |  |  |  |  |  | ); | 
| 700 |  |  |  |  |  |  |  | 
| 701 |  |  |  |  |  |  | __[ devel_cover ]__ | 
| 702 |  |  |  |  |  |  | #!{interpreter_path} | 
| 703 |  |  |  |  |  |  |  | 
| 704 |  |  |  |  |  |  | use strict; | 
| 705 |  |  |  |  |  |  | use warnings; | 
| 706 |  |  |  |  |  |  |  | 
| 707 |  |  |  |  |  |  | use lib qw( {libs} ); | 
| 708 |  |  |  |  |  |  |  | 
| 709 |  |  |  |  |  |  | use Devel::Cover qw( | 
| 710 |  |  |  |  |  |  | -summary 0 | 
| 711 |  |  |  |  |  |  | -silent 1 | 
| 712 |  |  |  |  |  |  | -db {cover_db_path} | 
| 713 |  |  |  |  |  |  | +ignore .git | 
| 714 |  |  |  |  |  |  | -merge 1 | 
| 715 |  |  |  |  |  |  | ); | 
| 716 |  |  |  |  |  |  | use App::GitHooks; | 
| 717 |  |  |  |  |  |  |  | 
| 718 |  |  |  |  |  |  |  | 
| 719 |  |  |  |  |  |  | App::GitHooks->run( | 
| 720 |  |  |  |  |  |  | name      => $0, | 
| 721 |  |  |  |  |  |  | arguments => \@ARGV, | 
| 722 |  |  |  |  |  |  | ); |