aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitaram Chamarty <sitaramc@gmail.com>2019-06-11 11:53:30 +0530
committerSitaram Chamarty <sitaramc@gmail.com>2019-06-13 19:40:59 +0530
commitef9ab68412cbee93c24eb920dbabbb6daa8b1c08 (patch)
tree4b48422354a246acc5bf7f92bac2758154f9e7e8
parentRepoUmask: mention the need for a manual chmod for existing repos (diff)
downloadgitolite-gentoo-ef9ab68412cbee93c24eb920dbabbb6daa8b1c08.tar.gz
gitolite-gentoo-ef9ab68412cbee93c24eb920dbabbb6daa8b1c08.tar.bz2
gitolite-gentoo-ef9ab68412cbee93c24eb920dbabbb6daa8b1c08.zip
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!
-rwxr-xr-xsrc/triggers/repo-specific-hooks18
1 files 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;