external programs can get settings from rc; see below

non-core programs can get their settings from the rc file also.
cpu-time is a perl example and desc is a shell example.

(info is not a good example because it does not use "Gitolite::Easy")
This commit is contained in:
Sitaram Chamarty 2012-03-22 14:45:30 +05:30
parent 0b8b144630
commit 0748b1225b
4 changed files with 61 additions and 1 deletions

28
src/commands/cpu-time Executable file
View file

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

View file

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

View file

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