changes to custom command invocation etc.; see below
- 'post-compile' subdir moved under 'commands/' but only for sanity; has no real significance now - new, internal use only, gitolite command run-all, as in gitolite run-all POST_COMPILE which runs all the commands in @{ $rc{POST_COMPILE} } in sequence. You can sdo this for any section of course, though this is the only one in the rc right now. (Future candidates: PRE_GIT, POST_GIT, PRE_CREATE, POST_CREATE)
This commit is contained in:
parent
efe37fb8a3
commit
876b554fb5
|
@ -30,25 +30,7 @@ sub post_update {
|
||||||
tsh_try("git checkout -f --quiet master");
|
tsh_try("git checkout -f --quiet master");
|
||||||
}
|
}
|
||||||
_system("$ENV{GL_BINDIR}/gitolite compile");
|
_system("$ENV{GL_BINDIR}/gitolite compile");
|
||||||
|
_system("$ENV{GL_BINDIR}/gitolite run-all POST_COMPILE");
|
||||||
# now run optional post-compile features
|
|
||||||
if ( exists $rc{POST_COMPILE} ) {
|
|
||||||
if ( ref( $rc{POST_COMPILE} ) ne 'ARRAY' ) {
|
|
||||||
_warn "bad syntax for specifying post compile scripts; see docs";
|
|
||||||
} else {
|
|
||||||
for my $s ( @{ $rc{POST_COMPILE} } ) {
|
|
||||||
|
|
||||||
# perl-ism; apart from keeping the full path separate from the
|
|
||||||
# simple name, this also protects %rc from change by implicit
|
|
||||||
# aliasing, which would happen if you touched $s itself
|
|
||||||
my $sfp = "$ENV{GL_BINDIR}/post-compile/$s";
|
|
||||||
|
|
||||||
_warn("skipped post-compile script '$s'"), next if not -x $sfp;
|
|
||||||
trace( 2, "post-compile $s" );
|
|
||||||
_system( $sfp, @ARGV ); # they better all return with 0 exit codes!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,13 +196,14 @@ __DATA__
|
||||||
# these will run in sequence after post-update
|
# these will run in sequence after post-update
|
||||||
POST_COMPILE =>
|
POST_COMPILE =>
|
||||||
[
|
[
|
||||||
'ssh-authkeys',
|
'post-compile/ssh-authkeys',
|
||||||
],
|
],
|
||||||
|
|
||||||
# comment out or uncomment as needed
|
# comment out or uncomment as needed
|
||||||
# these are available to remote users
|
# these are available to remote users
|
||||||
COMMANDS =>
|
COMMANDS =>
|
||||||
{
|
{
|
||||||
|
'help' => 1,
|
||||||
'info' => 1,
|
'info' => 1,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,7 +36,7 @@ sub setup {
|
||||||
setup_gladmin( $admin, $pubkey, $argv );
|
setup_gladmin( $admin, $pubkey, $argv );
|
||||||
|
|
||||||
_system("$ENV{GL_BINDIR}/gitolite compile");
|
_system("$ENV{GL_BINDIR}/gitolite compile");
|
||||||
_system("$ENV{GL_BINDIR}/gitolite post-compile ssh-authkeys") if $pubkey;
|
_system("$ENV{GL_BINDIR}/gitolite run-all POST_COMPILE");
|
||||||
|
|
||||||
hook_repos(); # all of them, just to be sure
|
hook_repos(); # all of them, just to be sure
|
||||||
}
|
}
|
||||||
|
|
34
src/commands/help
Executable file
34
src/commands/help
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use lib $ENV{GL_BINDIR};
|
||||||
|
use Gitolite::Rc;
|
||||||
|
use Gitolite::Common;
|
||||||
|
|
||||||
|
=for usage
|
||||||
|
Usage: gitolite help
|
||||||
|
|
||||||
|
Prints a list of custom commands available at this gitolite installation.
|
||||||
|
=cut
|
||||||
|
|
||||||
|
my $user = $ENV{GL_USER} || '';
|
||||||
|
print "hello" . ( $user ? " $user" : "") . ", this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
|
||||||
|
|
||||||
|
_chdir("$ENV{GL_BINDIR}/commands");
|
||||||
|
|
||||||
|
print "list of " . ($user ? "remote" : "gitolite" ) . " commands available:\n\n";
|
||||||
|
|
||||||
|
for my $c (`find . -type f|sort`) {
|
||||||
|
chomp($c);
|
||||||
|
$c =~ s(^./)();
|
||||||
|
next unless -x $c;
|
||||||
|
|
||||||
|
# if it's from a remote client, show only what he is allowed
|
||||||
|
next if $user and not $rc{COMMANDS}{$c};
|
||||||
|
|
||||||
|
print "\t$c\n";
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
exit 0;
|
|
@ -14,7 +14,8 @@ $|++;
|
||||||
# arguments anyway, it hardly matters.
|
# arguments anyway, it hardly matters.
|
||||||
|
|
||||||
my $ab = `gitolite query-rc -n GL_ADMIN_BASE`;
|
my $ab = `gitolite query-rc -n GL_ADMIN_BASE`;
|
||||||
_warn("'keydir' not found in '$ab'"), exit if not -d "$ab/keydir";
|
trace( 2, "'keydir' not found in '$ab'; exiting" ), exit if not -d "$ab/keydir";
|
||||||
|
my $akdir = "$ENV{HOME}/.ssh";
|
||||||
my $akfile = "$ENV{HOME}/.ssh/authorized_keys";
|
my $akfile = "$ENV{HOME}/.ssh/authorized_keys";
|
||||||
my $glshell = `gitolite query-rc -n GL_BINDIR` . "/gitolite-shell";
|
my $glshell = `gitolite query-rc -n GL_BINDIR` . "/gitolite-shell";
|
||||||
# XXX gl-time not yet coded (GL_PERFLOGT)
|
# XXX gl-time not yet coded (GL_PERFLOGT)
|
||||||
|
@ -58,11 +59,14 @@ if (@gl_keys) {
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
sub sanity {
|
sub sanity {
|
||||||
_warn "$akfile missing; creating a new one" if not -f $akfile;
|
|
||||||
_die "$glshell not found; this should NOT happen..." if not -f $glshell;
|
_die "$glshell not found; this should NOT happen..." if not -f $glshell;
|
||||||
_die "$glshell found but not readable; this should NOT happen..." if not -r $glshell;
|
_die "$glshell found but not readable; this should NOT happen..." if not -r $glshell;
|
||||||
_die "$glshell found but not executable; this should NOT happen..." if not -x $glshell;
|
_die "$glshell found but not executable; this should NOT happen..." if not -x $glshell;
|
||||||
|
|
||||||
|
_warn "$akdir missing; creating a new one" if not -d $akdir;
|
||||||
|
_warn "$akfile missing; creating a new one" if not -f $akfile;
|
||||||
|
|
||||||
|
_mkdir($akdir, 0700) if not -d $akfile;
|
||||||
if ( not -f $akfile ) {
|
if ( not -f $akfile ) {
|
||||||
_print( $akfile, "" );
|
_print( $akfile, "" );
|
||||||
chmod 0700, $akfile;
|
chmod 0700, $akfile;
|
63
src/gitolite
63
src/gitolite
|
@ -6,14 +6,13 @@
|
||||||
=for args
|
=for args
|
||||||
Usage: gitolite [sub-command] [options]
|
Usage: gitolite [sub-command] [options]
|
||||||
|
|
||||||
The following subcommands are available; they should all respond to '-h' if
|
The following built-in subcommands are available; they should all respond to
|
||||||
you want further details on each:
|
'-h' if you want further details on each:
|
||||||
|
|
||||||
setup 1st run: initial setup; all runs: hook fixups
|
setup 1st run: initial setup; all runs: hook fixups
|
||||||
compile compile gitolite.conf
|
compile compile gitolite.conf
|
||||||
|
|
||||||
query-rc get values of rc variables
|
query-rc get values of rc variables
|
||||||
post-compile run a post-compile command
|
|
||||||
|
|
||||||
list-groups list all group names in conf
|
list-groups list all group names in conf
|
||||||
list-users list all users/user groups in conf
|
list-users list all users/user groups in conf
|
||||||
|
@ -26,6 +25,10 @@ Warnings:
|
||||||
- list-users is disk bound and could take a while on sites with 1000s of repos
|
- list-users is disk bound and could take a while on sites with 1000s of repos
|
||||||
- list-memberships does not check if the name is known; unknown names come
|
- list-memberships does not check if the name is known; unknown names come
|
||||||
back with 2 answers: the name itself and '@all'
|
back with 2 answers: the name itself and '@all'
|
||||||
|
|
||||||
|
In addition, running 'gitolite help' should give you a list of custom commands
|
||||||
|
available. They may or may not respond to '-h', depending on how they were
|
||||||
|
written.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
@ -65,8 +68,8 @@ if ( $command eq 'setup' ) {
|
||||||
Gitolite::Conf->import;
|
Gitolite::Conf->import;
|
||||||
compile(@args);
|
compile(@args);
|
||||||
|
|
||||||
} elsif ( $command eq 'post-compile' ) {
|
} elsif ( $command eq 'run-all' ) {
|
||||||
post_compile(@args);
|
run_all(@args);
|
||||||
|
|
||||||
} elsif ( -x "$rc{GL_BINDIR}/commands/$command" ) {
|
} elsif ( -x "$rc{GL_BINDIR}/commands/$command" ) {
|
||||||
trace( 2, "attempting gitolite command $command" );
|
trace( 2, "attempting gitolite command $command" );
|
||||||
|
@ -93,36 +96,32 @@ sub args {
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
=for post_compile
|
|
||||||
Usage: gitolite post-compile [-l] [post-compile-scriptname] [script args...]
|
|
||||||
|
|
||||||
-l list currently available post-compile scripts
|
|
||||||
|
|
||||||
Run a post-compile script (which normally runs from the post-update hook in
|
|
||||||
the gitolite-admin repo).
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub post_compile {
|
|
||||||
usage() if ( not @_ or $_[0] eq '-h' );
|
|
||||||
|
|
||||||
run_subdir( 'post-compile', @_ );
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run_command {
|
sub run_command {
|
||||||
run_subdir( 'commands', @_ );
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run_subdir {
|
|
||||||
my $subdir = shift;
|
|
||||||
if ( @_ and $_[0] eq '-l' ) {
|
|
||||||
_chdir("$ENV{GL_BINDIR}/$subdir");
|
|
||||||
map { say2($_) } grep { -x } glob("*");
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $pgm = shift;
|
my $pgm = shift;
|
||||||
my $fullpath = "$ENV{GL_BINDIR}/$subdir/$pgm";
|
my $fullpath = "$ENV{GL_BINDIR}/commands/$pgm";
|
||||||
_die "$pgm not found or not executable" if not -x $fullpath;
|
_die "$pgm not found or not executable" if not -x $fullpath;
|
||||||
_system( $fullpath, @_ );
|
_system( $fullpath, @_ );
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub run_all {
|
||||||
|
my $rc_section = shift;
|
||||||
|
|
||||||
|
if ( exists $rc{$rc_section} ) {
|
||||||
|
if ( ref( $rc{$rc_section} ) ne 'ARRAY' ) {
|
||||||
|
_warn "$rc_section section in rc file is not a perl list";
|
||||||
|
} else {
|
||||||
|
for my $s ( @{ $rc{$rc_section} } ) {
|
||||||
|
|
||||||
|
# perl-ism; apart from keeping the full path separate from the
|
||||||
|
# simple name, this also protects %rc from change by implicit
|
||||||
|
# aliasing, which would happen if you touched $s itself
|
||||||
|
my $sfp = "$ENV{GL_BINDIR}/commands/$s";
|
||||||
|
|
||||||
|
_warn("skipped command '$s'"), next if not -x $sfp;
|
||||||
|
trace( 2, "command: $s" );
|
||||||
|
_system( $sfp, @ARGV ); # they better all return with 0 exit codes!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,15 +11,15 @@ $ENV{GL_BINDIR} = "$ENV{PWD}/src";
|
||||||
my $ak = "$ENV{HOME}/.ssh/authorized_keys";
|
my $ak = "$ENV{HOME}/.ssh/authorized_keys";
|
||||||
my $kd = `gitolite query-rc -n GL_ADMIN_BASE` . "/keydir";
|
my $kd = `gitolite query-rc -n GL_ADMIN_BASE` . "/keydir";
|
||||||
|
|
||||||
try "plan 50";
|
try "plan 49";
|
||||||
|
|
||||||
my $pgm = "gitolite post-compile ssh-authkeys";
|
my $pgm = "gitolite post-compile/ssh-authkeys";
|
||||||
|
|
||||||
try "
|
try "
|
||||||
# prep
|
# prep
|
||||||
rm -rf $ak; ok
|
rm -rf $ak; ok
|
||||||
|
|
||||||
$pgm; ok; /'keydir' not found/
|
$pgm; ok
|
||||||
mkdir $kd; ok
|
mkdir $kd; ok
|
||||||
cd $kd; ok
|
cd $kd; ok
|
||||||
$pgm; ok; /authorized_keys missing/
|
$pgm; ok; /authorized_keys missing/
|
||||||
|
|
|
@ -26,7 +26,7 @@ try "
|
||||||
cp $bd/../t/keys/*.pub $ab/keydir; ok or die 6
|
cp $bd/../t/keys/*.pub $ab/keydir; ok or die 6
|
||||||
";
|
";
|
||||||
|
|
||||||
_system("gitolite post-compile ssh-authkeys");
|
_system("gitolite post-compile/ssh-authkeys");
|
||||||
|
|
||||||
# basic tests
|
# basic tests
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue