gitolite/gitolite
Sitaram Chamarty d88cdbefd6 'gitolite list-users' added (but see warnings)
this is pretty slow if you have thousands of repos, since it has to read
and parse a 'gl-conf' file for every repo.  (For example, on a Lenovo
X201 thinkpad with 11170 repos and a cold cache, it took 288 seconds).

(With a hot cache -- like if you run the command again -- it took 2.1
seconds!  So if you have a fast disk this may not be an issue for you
even if you have 10,000+ repos).
2012-03-24 10:30:41 +05:30

70 lines
2 KiB
Perl
Executable file

#!/usr/bin/perl
# all gitolite CLI tools run as sub-commands of this command
# ----------------------------------------------------------------------
=for usage
Usage: gitolite [sub-command] [options]
The following subcommands are available; they should all respond to '-h':
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 user names in conf
Warnings:
- list-users is disk bound and could take a while on sites with thousands of repos
=cut
# ----------------------------------------------------------------------
use FindBin;
BEGIN { $ENV{GL_BINDIR} = $FindBin::Bin; }
use lib $ENV{GL_BINDIR};
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::Commands::Setup;
Gitolite::Commands::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;
require Gitolite::Commands::QueryRc;
Gitolite::Commands::QueryRc->import;
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() } );
}
}