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:
parent
0b8b144630
commit
0748b1225b
|
@ -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',
|
||||
],
|
||||
);
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
28
src/commands/cpu-time
Executable file
28
src/commands/cpu-time
Executable 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 );
|
||||
}
|
||||
|
|
@ -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!
|
||||
|
||||
# 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
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in a new issue