From ef9ab68412cbee93c24eb920dbabbb6daa8b1c08 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Tue, 11 Jun 2019 11:53:30 +0530 Subject: repo-specific hooks: fix bug in handling reserved hooks There are two points to consider here: - is the user trying to delete all hooks for a repo? - is it a reserved hook (one we should not be touching) The second one is more important; the first one is a spurious warning that is at worst an aesthetic problem. Unfortunately, when refactoring to fix a bug in 7898f9b, I gave higher priority to the wrong issue, and the more important one was not checked when the less important one was "true". As a result, control moved to the second stage, where hooks were symlinked to the multi-hook driver. Including the all important 'post-update' hook in 'gitolite-admin'. Ouch! --- src/triggers/repo-specific-hooks | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/triggers/repo-specific-hooks b/src/triggers/repo-specific-hooks index 7c16f2f..4044cc9 100755 --- a/src/triggers/repo-specific-hooks +++ b/src/triggers/repo-specific-hooks @@ -42,19 +42,17 @@ while (<>) { my @codes = split /\s+/, $codes; - # 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)$/ ) { + # bail on disallowed hook types (but warn only if @codes is non-empty) + 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" if @codes; + next; + } + unless ( $hook =~ /^(pre-receive|post-receive|post-update|pre-auto-gc)$/ ) { + if (@codes) { _warn "repo-specific-hooks: '$hook' is not allowed, ignoring"; _warn " (only pre-receive, post-receive, post-update, and pre-auto-gc are allowed)"; - next; } + next; } push @{ $repo_hooks{$repo}{$hook} }, @codes; -- cgit v1.2.3-65-gdbad