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 | |
parent | clean up previous patch on handling trailing slashes (diff) | |
download | gitolite-gentoo-7898f9b020e8106e5165d547ce97e4ef6a0f5d7e.tar.gz gitolite-gentoo-7898f9b020e8106e5165d547ce97e4ef6a0f5d7e.tar.bz2 gitolite-gentoo-7898f9b020e8106e5165d547ce97e4ef6a0f5d7e.zip |
fix bug when deleting ALL hooks for a repo
-rwxr-xr-x | src/triggers/repo-specific-hooks | 24 | ||||
-rwxr-xr-x | t/repo-specific-hooks.t | 12 |
2 files changed, 19 insertions, 17 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) { diff --git a/t/repo-specific-hooks.t b/t/repo-specific-hooks.t index 6cacdb2..90a23c6 100755 --- a/t/repo-specific-hooks.t +++ b/t/repo-specific-hooks.t @@ -173,10 +173,10 @@ try " # Verify hooks are removed properly -confreset;confadd ' +confadd ' repo foo RW+ = @all - option hook.post-receive = + option hook.post-receive = "" repo bar RW+ = @all @@ -184,17 +184,17 @@ confreset;confadd ' repo baz RW+ = @all - option hook.post-receive = + option hook.post-receive = "" option hook.post-update = second '; try "ADMIN_PUSH repo-specific-hooks-02; !/FATAL/" or die text(); try " - ls $rb/foo.git/hooks/*; ok; !/post-receive/ + ls $rb/foo.git/hooks/*; ok; !/post-receive.h0/ ls $rb/bar.git/hooks/*; ok; !/pre-receive.*first/ /pre-receive.h00-second/ - ls $rb/baz.git/hooks/*; ok; !/post-receive/ + ls $rb/baz.git/hooks/*; ok; !/post-receive.h0/ !/post-update.*first/ /post-update.h00-second/ "; @@ -216,7 +216,7 @@ try " PUSH admin master; ok; /master -. master/ /hooks/pre-receive.h00-second/ !/hooks/pre-receive.*has args:/ - /hooks/pre-receive.h00-second has stdin: 0000000000000000000000000000000000000000 cc7808f77c7c7d705f82dc54dc3152146175768f refs/heads/master/ + /hooks/pre-receive.h00-second has stdin: cfc8561c7827a8b94df6c5dad156383d4cb210f5 cc7808f77c7c7d705f82dc54dc3152146175768f refs/heads/master/ cd .. |