File: setup.pl

package info (click to toggle)
libdatetime-perl 2%3A1.65-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,920 kB
  • sloc: perl: 2,986; sh: 23; makefile: 3
file content (27 lines) | stat: -rwxr-xr-x 500 bytes parent folder | download | duplicates (29)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env perl

use strict;
use warnings;

use Cwd qw( abs_path );

symlink_hook('pre-commit');

sub symlink_hook {
    my $hook = shift;

    my $dot  = ".git/hooks/$hook";
    my $file = "git/hooks/$hook.sh";
    my $link = "../../$file";

    if ( -e $dot ) {
        if ( -l $dot ) {
            return if readlink $dot eq $link;
        }
        warn "You already have a hook at $dot!\n";
        return;
    }

    symlink $link, $dot
        or die "Could not link $dot => $link: $!";
}