make dev_gateway default to port 3000
[sgn-devtools.git] / svn-hooks / install_cxgn_svn_hooks.pl
blob190bd03eba9869a13a764217b6c836ccdcca3d5a
1 #!/usr/bin/perl
3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
6 use strict;
7 use warnings;
9 use English;
10 use Carp;
11 use FindBin;
13 use Getopt::Std;
14 use Pod::Usage;
16 use List::MoreUtils qw/uniq/;
18 #use Data::Dumper;
20 our %opt;
21 getopts('',\%opt) or pod2usage(1);
23 my ($repos_path) = @ARGV;
25 #check the repos path we were given
26 $repos_path or pod2usage(1);
27 -d $repos_path or die "repo path does not exist";
28 -f "$repos_path/format" && -d "$repos_path/hooks" && -d "$repos_path/conf"
29 or die "'$repos_path' does not appear to be a valid svn repository.\n";
31 my $conf_dir = "$repos_path/conf";
32 my $conf_file = "$FindBin::RealBin/svn-hooks.conf";
33 my $conf_tgt = "$conf_dir/svn-hooks.conf";
34 my $hook_script = "$FindBin::RealBin/svn-hooks.pl";
35 my $hook_dir = "$repos_path/hooks";
36 my @hook_tgts = uniq
37 (map { s/\.tmpl$//; $_} glob "$hook_dir/*.tmpl"),
38 (map {"$repos_path/hooks/$_"} qw/pre-commit post-commit pre-revprop-change/);
41 -f $conf_file or die "conf file '$conf_file' not found, aborting";
42 -f $hook_script or die "hook script '$hook_script' not found, aborting";
43 -w or die "could not write to '$_'" foreach $conf_dir, $hook_dir;
45 unlink $conf_tgt;
46 symlink($conf_file, $conf_tgt) or die "$! linking '$conf_file' -> '$conf_tgt'";
48 foreach my $t (@hook_tgts) {
49 unlink $t;
50 symlink( $hook_script, $t ) or die "$! linking '$hook_script' -> '$t'";
56 __END__
58 =head1 NAME
60 install_hooks.pl - tiny script to just install the accompanying svn
61 hooks and configuration into the SVN repository at the given path
63 =head1 SYNOPSIS
65 install_hooks.pl [options] repos_path
67 Options:
69 none yet
71 =cut