diff options
Diffstat (limited to 'src/triggers/repo-specific-hooks')
-rwxr-xr-x | src/triggers/repo-specific-hooks | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/triggers/repo-specific-hooks b/src/triggers/repo-specific-hooks index bba7a58..7c16f2f 100755 --- a/src/triggers/repo-specific-hooks +++ b/src/triggers/repo-specific-hooks @@ -41,21 +41,23 @@ while (<>) { $hook =~ s/\..*//; my @codes = split /\s+/, $codes; - next unless @codes; - # this is a special case - if ( $repo eq 'gitolite-admin' and $hook eq 'post-update' ) { - _warn "repo-specific-hooks: ignoring attempts to set post-update hook for the admin repo"; - next; - } + # check for disallowed hook types only if @codes is non-empty + if (@codes) { + # this is a special case + if ( $repo eq 'gitolite-admin' and $hook eq 'post-update' ) { + _warn "repo-specific-hooks: ignoring attempts to set post-update hook for the admin repo"; + next; + } - unless ( $hook =~ /^(pre-receive|post-receive|post-update|pre-auto-gc)$/ ) { - _warn "repo-specific-hooks: '$hook' is not allowed, ignoring"; - _warn " (only pre-receive, post-receive, post-update, and pre-auto-gc are allowed)"; - next; + unless ( $hook =~ /^(pre-receive|post-receive|post-update|pre-auto-gc)$/ ) { + _warn "repo-specific-hooks: '$hook' is not allowed, ignoring"; + _warn " (only pre-receive, post-receive, post-update, and pre-auto-gc are allowed)"; + next; + } } - push @{ $repo_hooks{$repo}{$hook} }, @codes if @codes; + push @{ $repo_hooks{$repo}{$hook} }, @codes; } for my $repo (keys %repo_hooks) { @@ -111,8 +113,8 @@ for h in $0.*; do [ -x $h ] || continue if [ $type = args ] then - $h $@ + $h $@ || { [ $0 = hooks/pre-receive ] && exit 1; } else - echo "$stdin" | $h + echo "$stdin" | $h || { [ $0 = hooks/pre-receive ] && exit 1; } fi done |