line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Repository::Plugin::Hooks; |
2
|
1
|
|
|
1
|
|
16333
|
use parent qw(Git::Repository::Plugin); |
|
1
|
|
|
|
|
339
|
|
|
1
|
|
|
|
|
17
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use 5.008005; |
5
|
|
|
|
|
|
|
use strict; |
6
|
|
|
|
|
|
|
use warnings; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Carp qw(); |
9
|
|
|
|
|
|
|
use File::Copy qw(); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _keywords { qw( |
14
|
|
|
|
|
|
|
install_hook |
15
|
|
|
|
|
|
|
hook_path |
16
|
|
|
|
|
|
|
) } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub install_hook { |
19
|
|
|
|
|
|
|
my ($repo, $source, $target) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $dest = $repo->hook_path($target); |
22
|
|
|
|
|
|
|
my $copy_rv = File::Copy::copy($source, $dest); |
23
|
|
|
|
|
|
|
unless ($copy_rv) { |
24
|
|
|
|
|
|
|
Carp::croak "install_hook failed: $!"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $chmod_rv = chmod 0755, $dest; |
28
|
|
|
|
|
|
|
unless ($chmod_rv) { |
29
|
|
|
|
|
|
|
Carp::croak "install_hook failed: $!"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub hook_path { |
34
|
|
|
|
|
|
|
my ($repo, $target) = @_; |
35
|
|
|
|
|
|
|
return File::Spec->join($repo->git_dir, 'hooks', $target); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |