Debian Codegraph @

git/setup.pl

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use Cwd qw( abs_path );
7
8 symlink_hook('pre-commit');
9
10 sub symlink_hook {
11 my $hook = shift;
12
13 my $dot = ".git/hooks/$hook";
14 my $file = "git/hooks/$hook.sh";
15 my $link = "../../$file";
16
17 if ( -e $dot ) {
18 if ( -l $dot ) {
19 return if readlink $dot eq $link;
20 }
21 warn "You already have a hook at $dot!\n";
22 return;
23 }
24
25 symlink $link, $dot
26 or die "Could not link $dot => $link: $!";
27 }