diff options
author | Sitaram Chamarty <sitaramc@gmail.com> | 2018-01-31 14:09:08 +0530 |
---|---|---|
committer | Sitaram Chamarty <sitaramc@gmail.com> | 2018-02-11 11:45:39 +0530 |
commit | 7898f9b020e8106e5165d547ce97e4ef6a0f5d7e (patch) | |
tree | ed02c6aa735f90b2be771b8a2408509ea3eaa13b /src | |
parent | 2cfc81f230a06f629bc977baa66a149adcdbedec (diff) |
fix bug when deleting ALL hooks for a repo
Diffstat (limited to 'src')
-rwxr-xr-x | src/triggers/repo-specific-hooks | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/triggers/repo-specific-hooks b/src/triggers/repo-specific-hooks index a4c86cc..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) { |