gitolite setup learns --hooks-only option

This commit is contained in:
Sitaram Chamarty 2012-05-25 06:07:10 +05:30
parent e1d9aee98b
commit 17841e8208

View file

@ -6,21 +6,30 @@ package Gitolite::Setup;
=for args =for args
Usage: gitolite setup [<option>] Usage: gitolite setup [<option>]
-pk, --pubkey <file> pubkey file name Setup gitolite, compile conf, run the POST_COMPILE trigger (see rc file) and
-a, --admin <name> admin name propagate hooks.
Setup gitolite, compile conf, and fixup hooks. Either the pubkey or the admin -a, --admin <name> admin name
name is required on the first run, depending on whether you're using ssh mode -pk, --pubkey <file> pubkey file name
or http mode. -ho, --hooks-only skip other steps and just propagate hooks
First run: either the pubkey or the admin name is *required*, depending on
whether you're using ssh mode or http mode.
Subsequent runs: Subsequent runs:
- 'gitolite setup': fix up hooks if you brought in repos from outside, or if - Without options, 'gitolite setup' is a general "fix up everything" command
someone has been playing around with the hooks and may have deleted some. (for example, if you brought in repos from outside, or someone messed
around with the hooks, or you made an rc file change that affects access
rules, etc.)
- '-pk' can be used to replace the admin key; useful if you lost the admin's
private key but do have shell access to the server.
- '-ho' is mainly for scripting use. Do not combine with other options.
- '-a' is ignored
- 'gitolite setup -pk YourName.pub': replace keydir/YourName.pub and
recompile/push. Useful if you lost your key. In fact you can do this for
any key in keydir (but not in subdirectories).
=cut =cut
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -42,12 +51,15 @@ use warnings;
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
sub setup { sub setup {
my ( $admin, $pubkey, $argv ) = args(); my ( $admin, $pubkey, $h_only, $argv ) = args();
unless ($h_only) {
setup_glrc(); setup_glrc();
setup_gladmin( $admin, $pubkey, $argv ); setup_gladmin( $admin, $pubkey, $argv );
_system("gitolite compile"); _system("gitolite compile");
_system("gitolite trigger POST_COMPILE"); _system("gitolite trigger POST_COMPILE");
}
hook_repos(); # all of them, just to be sure hook_repos(); # all of them, just to be sure
} }
@ -57,16 +69,19 @@ sub setup {
sub args { sub args {
my $admin = ''; my $admin = '';
my $pubkey = ''; my $pubkey = '';
my $h_only = 0;
my $help = 0; my $help = 0;
my $argv = join( " ", @ARGV ); my $argv = join( " ", @ARGV );
GetOptions( GetOptions(
'admin|a=s' => \$admin, 'admin|a=s' => \$admin,
'pubkey|pk=s' => \$pubkey, 'pubkey|pk=s' => \$pubkey,
'hooks-only|ho' => \$h_only,
'help|h' => \$help, 'help|h' => \$help,
) or usage(); ) or usage();
usage() if $help or ( $pubkey and $admin ); usage() if $help or ( $pubkey and $admin );
usage() if $h_only and ($admin or $pubkey);
if ($pubkey) { if ($pubkey) {
$pubkey =~ /\.pub$/ or _die "'$pubkey' name does not end in .pub"; $pubkey =~ /\.pub$/ or _die "'$pubkey' name does not end in .pub";
@ -80,7 +95,7 @@ sub args {
$admin =~ s/\.pub$//; $admin =~ s/\.pub$//;
} }
return ( $admin || '', $pubkey || '', $argv ); return ( $admin || '', $pubkey || '', $h_only || 0, $argv );
} }
sub setup_glrc { sub setup_glrc {