diff --git a/src/Gitolite/Rc.pm b/src/Gitolite/Rc.pm index 6b501b1..4d9299c 100644 --- a/src/Gitolite/Rc.pm +++ b/src/Gitolite/Rc.pm @@ -238,6 +238,18 @@ __DATA__ UMASK => 0077, GIT_CONFIG_KEYS => '', + # settings used by external programs; uncomment and change as needed. You + # can add your own variables for use in your own external programs; take a + # look at the cpu-time and desc commands for perl and shell samples. + + # used by the cpu-time command + # DISPLAY_CPU_TIME => 1, + # CPU_TIME_WARN_LIMIT => 0.1, + # used by the desc command + # WRITER_CAN_UPDATE_DESC => 1, + # used by the info command + # SITE_INFO => 'Please see http://blahblah/gitolite for more help', + # add more roles (like MANAGER, TESTER, ...) here ROLES => { @@ -283,6 +295,14 @@ __DATA__ 'perms' => 1, 'writes' => 1, }, + + # comment out or uncomment as needed + # these will run in sequence at the end, after a git operation has ended + POST_GIT => + [ + # if you use this, make this the last item in the list + # 'cpu-time', + ], ); # ------------------------------------------------------------------------------ diff --git a/src/commands/cpu-time b/src/commands/cpu-time new file mode 100755 index 0000000..d363328 --- /dev/null +++ b/src/commands/cpu-time @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use lib $ENV{GL_BINDIR}; +use Gitolite::Easy; + +my ($trigger, $repo, $user, $aa, $ref, $verb, $utime, $stime, $cutime, $cstime) = @ARGV; + +# now do whatever you want with this data; the following is just an example. + +# Ideally, you will (a) write your own code with a different filename so later +# gitolite upgrades won't overwrite your copy, (b) add appropriate variables +# to the rc file, and (c) change your rc file to call your program at the end +# of the POST_GIT list. + +if (my $limit = $rc{CPU_TIME_WARN_LIMIT}) { + my $total = $utime + $cutime + $stime + $cstime; + # some code to send an email or whatever... + say2 "limit = $limit, actual = $total" if $total > $limit; +} + +if ($rc{DISPLAY_CPU_TIME}) { + say2 "perf stats for $verb on repo '$repo':"; + say2 " user CPU time: " . ( $utime + $cutime ); + say2 " sys CPU time: " . ( $stime + $cstime ); +} + diff --git a/src/commands/desc b/src/commands/desc index 77466ee..4fa3060 100755 --- a/src/commands/desc +++ b/src/commands/desc @@ -16,7 +16,17 @@ repo=$1; shift # this shell script takes arguments that are completely under the user's # control, so make sure you quote those suckers! -gitolite creator "$repo" $GL_USER || die You are not authorised + +# kernel.org needs 'desc' to be available to people who have "RW" or above, +# not just the "creator". In fact they need it for non-wild repos so there +# *is* no creator. +if gitolite query-rc -q WRITER_CAN_UPDATE_DESC +then + gitolite access -q "$repo" $GL_USER W any || die You are not authorised +else + gitolite creator "$repo" $GL_USER || die You are not authorised +fi + # if it passes, $repo is a valid repo name so it is known to contain only sane # characters. This is because 'gitolite creator' return true only if there # *is* a repo of that name and it has a gl-creator file that contains the same diff --git a/src/commands/info b/src/commands/info index 0c503e1..66b7e68 100755 --- a/src/commands/info +++ b/src/commands/info @@ -80,3 +80,5 @@ for my $repo (@$repos) { print "\t$creator" if $lc; print "\n"; } + +print "\n$rc{SITE_INFO}\n" if $rc{SITE_INFO};