diff --git a/conf/example.gitolite.rc b/conf/example.gitolite.rc index bda9d2d..b1a921f 100644 --- a/conf/example.gitolite.rc +++ b/conf/example.gitolite.rc @@ -158,6 +158,18 @@ $RSYNC_BASE = ""; # Please see doc/4-wildcard-repositories.mkd for details. $GL_WILDREPOS = 0; +# -------------------------------------- +# HOOK CHAINING + +# by default, the update hook in every repo chains to "update.secondary". +# Similarly, the post-update hook in the admin repo chains to +# "post-update.secondary". If you're fine with the defaults, there's no need +# to do anything here. However, if you want to use different names or paths, +# change these variables + +# $UPDATE_CHAINS_TO = "hooks/update.secondary"; +# $ADMIN_POST_UPDATE_CHAINS_TO = "hooks/post-update.secondary"; + # -------------------------------------- # per perl rules, this should be the last line in such a file: 1; diff --git a/doc/2-admin.mkd b/doc/2-admin.mkd index 4190fc6..4b27d59 100644 --- a/doc/2-admin.mkd +++ b/doc/2-admin.mkd @@ -131,6 +131,10 @@ if such a hook exists. People wishing to do exotic things on the server side when the admin repo is pushed should see doc/shell-games.notes for how to exploit this :-) +Finally, these names (`update.secondary` and `post-update.secondary`) are +merely the defaults. You can change them to anything you want; look in +conf/example.gitolite.rc for details. + #### custom git config The custom hooks feature is a blunt instrument -- all repos get the hook you diff --git a/hooks/common/update b/hooks/common/update index 2a3e3e6..dc87d03 100755 --- a/hooks/common/update +++ b/hooks/common/update @@ -25,7 +25,7 @@ use warnings; # common definitions # ---------------------------------------------------------------------------- -our ($GL_CONF_COMPILED); +our ($GL_CONF_COMPILED, $UPDATE_CHAINS_TO); our %repos; # people with shell access should be allowed to bypass the update hook, simply @@ -123,7 +123,8 @@ my $log_refex = check_ref(\@allowed_refs, $ENV{GL_REPO}, (shift @refs), $perm); "\t$reported_repo\t$ref\t$ENV{GL_USER}\t$log_refex\n"); # now chain to the local admin defined update hook, if present -exec "./hooks/update.secondary", @saved_ARGV - if -f "hooks/update.secondary" or -l "hooks/update.secondary"; +$UPDATE_CHAINS_TO ||= 'hooks/update.secondary'; +exec $UPDATE_CHAINS_TO, @saved_ARGV + if -f $UPDATE_CHAINS_TO or -l $UPDATE_CHAINS_TO; exit 0; diff --git a/hooks/gitolite-admin/post-update b/hooks/gitolite-admin/post-update index 8fcb182..891c273 100755 --- a/hooks/gitolite-admin/post-update +++ b/hooks/gitolite-admin/post-update @@ -11,7 +11,10 @@ $GL_BINDIR/gl-compile-conf cd $od -if [ -f hooks/post-update.secondary ] || [ -L hooks/post-update.secondary ] +ADMIN_POST_UPDATE_CHAINS_TO=` cd;perl -e 'do ".gitolite.rc"; print $ADMIN_POST_UPDATE_CHAINS_TO'` +[ -n "$ADMIN_POST_UPDATE_CHAINS_TO" ] || ADMIN_POST_UPDATE_CHAINS_TO=hooks/post-update.secondary + +if [ -f $ADMIN_POST_UPDATE_CHAINS_TO ] || [ -L $ADMIN_POST_UPDATE_CHAINS_TO ] then - exec hooks/post-update.secondary "$@" + exec $ADMIN_POST_UPDATE_CHAINS_TO "$@" fi