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...
This commit is contained in:
Sitaram Chamarty 2010-03-14 22:07:34 +05:30
parent bf7aba7e0b
commit ed5c78349e
4 changed files with 23 additions and 4 deletions

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -59,9 +59,9 @@ 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 -R -p $bindir/../src $bindir/../doc $bindir/../hooks $GL_ADMINDIR");
system("cp $bindir/../conf/VERSION $GL_ADMINDIR/conf");
}