3 # A hook that notifies its companion cidaemon through a simple
4 # queue file that a ref has been updated via a push (actually
5 # by a receive-pack running on the server).
7 # See cidaemon for per-repository configuration details.
9 # To use this hook, add it as the post-receive hook, make it
10 # executable, and set its configuration options.
13 local $ENV{PATH} = '/opt/git/bin';
18 use Storable qw(retrieve nstore);
21 my $git_dir = File::Spec->rel2abs($ENV{GIT_DIR});
22 my $queue_name = `git config --get builder.queue`;chop $queue_name;
23 $queue_name =~ m,^([^\s]+)$,; $queue_name = $1; # untaint
24 unless ($queue_name) {
26 print STDERR "\nerror: builder.queue not set. Not enqueing.\n\n";
29 my $queue_lock = "$queue_name.lock";
32 open S, "git config --get-all builder.skip|";
40 open S, "git config --get-all builder.newBranchBase|";
43 push @new_branch_base, $_;
50 foreach my $p (@skip) {
56 open LOCK, ">$queue_lock" or die "Can't open $queue_lock: $!";
59 my $queue = -f $queue_name ? retrieve $queue_name : [];
61 foreach my $r (@$queue) {
63 $existing{$gd}{$ref} = $r;
66 my @new_branch_commits;
67 my $loaded_new_branch_commits = 0;
71 my ($old, $new, $ref) = split / /, $_, 3;
74 next if $new =~ /^0{40}$/;
77 my $r = $existing{$git_dir}{$ref};
81 if ($old =~ /^0{40}$/) {
82 if (!$loaded_new_branch_commits && @new_branch_base) {
83 open M,'-|','git','show-ref',@new_branch_base;
86 push @new_branch_commits, $_;
89 $loaded_new_branch_commits = 1;
91 $old = [@new_branch_commits];
96 $r = [$git_dir, $ref, $old, $new];
97 $existing{$git_dir}{$ref} = $r;
101 nstore $queue, $queue_name;