From ed5c78349e9e5f46ccff4e96d29ae41a75c3fc32 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sun, 14 Mar 2010 22:07:34 +0530 Subject: [PATCH] update hook now allows chaining to "update.secondary" the changes to cp/scp are because without "-p" they dont carry perms across to existing files. So if you forgot to chmod +x your custom hook and ran easy install, then after that you have to go to the server side to fix the perms... --- doc/2-admin.mkd | 12 ++++++++++++ hooks/common/update | 7 +++++++ src/gl-easy-install | 2 +- src/gl-install | 6 +++--- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/2-admin.mkd b/doc/2-admin.mkd index b5a6c08..c615fb8 100644 --- a/doc/2-admin.mkd +++ b/doc/2-admin.mkd @@ -10,6 +10,7 @@ In this document: * moving pre-existing repos into gitolite * specifying gitweb and daemon access * custom hooks + * when you need your own "update" hook * custom git config ### administer @@ -112,6 +113,17 @@ implements all the branch-level permissions in gitolite. If you fiddle with the hooks directory, please make sure you do not mess with this file accidentally, or all your fancy per-branch permissions will stop working.** +#### when you need your own "update" hook + +Gitolite basically takes over the update hook for all repos, but some setups +really need the update hook functionality for their own purposes too. In +order to allow this, Gitolite now exec's a hook called `update.secondary` when +it's own "update" hook is done and everything is ready to go. + +You can create this `update.secondary` hook selectively on some repos on the +server, or use the mechanism in the previous section to make gitolite install +it on *all* your repos. + #### 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 62f839b..3423522 100755 --- a/hooks/common/update +++ b/hooks/common/update @@ -54,6 +54,8 @@ require "$ENV{GL_BINDIR}/gitolite.pm"; # start... # ---------------------------------------------------------------------------- +my @saved_ARGV = @ARGV; # for chaining to another update hook at the end + my $ref = shift; my $oldsha = shift; my $newsha = shift; @@ -110,4 +112,9 @@ my $log_refex = check_ref(\@allowed_refs, $ENV{GL_REPO}, (shift @refs), $perm); &log_it("$ENV{GL_TS} $perm\t" . substr($oldsha, 0, 14) . "\t" . substr($newsha, 0, 14) . "\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"; + exit 0; diff --git a/src/gl-easy-install b/src/gl-easy-install index 75b7017..c4dfdb1 100755 --- a/src/gl-easy-install +++ b/src/gl-easy-install @@ -282,7 +282,7 @@ copy_gl() { # have to create the directory first. ssh -p $port $user@$host mkdir -p gitolite-install - scp $quiet -P $port -r src conf doc hooks $user@$host:gitolite-install/ + scp $quiet -P $port -p -r src conf doc hooks $user@$host:gitolite-install/ # MANUAL: now log on to the server (ssh git@server) and get a command # line. This step is for your convenience; the script does it all from diff --git a/src/gl-install b/src/gl-install index b163439..f24a0de 100755 --- a/src/gl-install +++ b/src/gl-install @@ -59,10 +59,10 @@ for my $dir qw(conf doc keydir logs src hooks hooks/common hooks/gitolite-admin) # "src" and "doc" will be overwritten on each install, but not conf if ($GL_PACKAGE_HOOKS) { - system("cp -R $GL_PACKAGE_HOOKS $GL_ADMINDIR"); + system("cp -R -p $GL_PACKAGE_HOOKS $GL_ADMINDIR"); } else { - system("cp -R $bindir/../src $bindir/../doc $bindir/../hooks $GL_ADMINDIR"); - system("cp $bindir/../conf/VERSION $GL_ADMINDIR/conf"); + system("cp -R -p $bindir/../src $bindir/../doc $bindir/../hooks $GL_ADMINDIR"); + system("cp $bindir/../conf/VERSION $GL_ADMINDIR/conf"); } unless (-f $GL_CONF or $GL_PACKAGE_CONF) {