gitolite/src/gitolite

126 lines
4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl
# all gitolite CLI tools run as sub-commands of this command
# ----------------------------------------------------------------------
=for usage
Usage: gitolite [sub-command] [options]
2012-03-11 17:03:15 +01:00
The following subcommands are available; they should all respond to '-h' if
you want further details on each:
setup 1st run: initial setup; all runs: hook fixups
compile compile gitolite.conf
query-rc get values of rc variables
list-groups list all group names in conf
list-users list all users/user groups in conf
list-repos list all repos/repo groups in conf
list-phy-repos list all repos actually on disk
list-memberships list all groups a name is a member of
list-members list all members of a group
2012-03-11 17:03:15 +01:00
post-compile run a post-compile command
Warnings:
- 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
back with 2 answers: the name itself and '@all'
=cut
# ----------------------------------------------------------------------
use FindBin;
BEGIN { $ENV{GL_BINDIR} = $FindBin::RealBin; }
use lib $ENV{GL_BINDIR};
use Gitolite::Rc;
use Gitolite::Common;
use strict;
use warnings;
# ----------------------------------------------------------------------
args();
# ----------------------------------------------------------------------
sub args {
my ( $command, @args ) = @ARGV;
usage() if not $command or $command eq '-h';
if ( $command eq 'setup' ) {
shift @ARGV;
require Gitolite::Setup;
Gitolite::Setup->import;
setup();
} elsif ( $command eq 'compile' ) {
shift @ARGV;
_die "'gitolite compile' does not take any arguments" if @ARGV;
require Gitolite::Conf;
Gitolite::Conf->import;
compile();
} elsif ( $command eq 'query-rc' ) {
shift @ARGV;
query_rc();
} elsif ( $command eq 'list-groups' ) {
shift @ARGV;
require Gitolite::Conf::Load;
Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_groups() } );
} elsif ( $command eq 'list-users' ) {
shift @ARGV;
require Gitolite::Conf::Load;
Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_users() } );
} elsif ( $command eq 'list-repos' ) {
shift @ARGV;
require Gitolite::Conf::Load;
Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_repos() } );
} elsif ( $command eq 'list-phy-repos' ) {
shift @ARGV;
_chdir( $rc{GL_REPO_BASE} );
print "$_\n" for ( @{ list_phy_repos() } );
} elsif ( $command eq 'list-memberships' ) {
shift @ARGV;
require Gitolite::Conf::Load;
Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_memberships() } );
} elsif ( $command eq 'list-members' ) {
shift @ARGV;
require Gitolite::Conf::Load;
Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_members() } );
2012-03-11 17:03:15 +01:00
} elsif ( $command eq 'post-compile' ) {
shift @ARGV;
post_compile();
} else {
_die "unknown gitolite sub-command";
}
}
2012-03-11 17:03:15 +01:00
=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('', 'post-compile') if (@ARGV and $ARGV[0] eq '-h');
if (@ARGV and $ARGV[0] eq '-l') {
_chdir("$ENV{GL_BINDIR}/post-compile");
map { say2($_) } grep { -x } glob("*");
exit 0;
}
my $pgm = shift @ARGV;
my $fullpath = "$ENV{GL_BINDIR}/post-compile/$pgm";
_die "$pgm not found or not executable" if not -x $fullpath;
_system($fullpath, @ARGV);
exit 0;
}