'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).
This commit is contained in:
parent
1be66dc10e
commit
d88cdbefd6
|
@ -8,6 +8,7 @@ package Gitolite::Conf::Load;
|
||||||
access
|
access
|
||||||
|
|
||||||
list_groups
|
list_groups
|
||||||
|
list_users
|
||||||
);
|
);
|
||||||
|
|
||||||
use Exporter 'import';
|
use Exporter 'import';
|
||||||
|
@ -188,5 +189,42 @@ sub list_groups {
|
||||||
return (sort_u(\@g));
|
return (sort_u(\@g));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub list_users {
|
||||||
|
my $count = 0;
|
||||||
|
my $total = 0;
|
||||||
|
|
||||||
|
die "\nUsage: gitolite list-users\n\n - no options, no flags\n - may be slow if you have thousands of repos\n\n" if @ARGV;
|
||||||
|
|
||||||
|
load_common();
|
||||||
|
|
||||||
|
my @u = map { keys %{ $_ } } values %repos;
|
||||||
|
$total = scalar(keys %split_conf);
|
||||||
|
warn "WARNING: you have $total repos to check; this could take some time!\n" if $total > 100;
|
||||||
|
for my $one ( keys %split_conf ) {
|
||||||
|
load_1($one);
|
||||||
|
$count++; print STDERR "$count / $total\r" if not ( $count % 100 ) and timer(5);
|
||||||
|
push @u, map { keys %{ $_ } } values %one_repo;
|
||||||
|
}
|
||||||
|
print STDERR "\n";
|
||||||
|
return (sort_u(\@u));
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
{
|
||||||
|
my $start_time = 0;
|
||||||
|
|
||||||
|
sub timer {
|
||||||
|
unless ($start_time) {
|
||||||
|
$start_time = time();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
my $elapsed = shift;
|
||||||
|
return 0 if time() - $start_time < $elapsed;
|
||||||
|
$start_time = time();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
9
gitolite
9
gitolite
|
@ -12,6 +12,10 @@ The following subcommands are available; they should all respond to '-h':
|
||||||
compile compile gitolite.conf
|
compile compile gitolite.conf
|
||||||
query-rc get values of rc variables
|
query-rc get values of rc variables
|
||||||
list-groups list all group names in conf
|
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
|
=cut
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
@ -56,5 +60,10 @@ sub args {
|
||||||
require Gitolite::Conf::Load;
|
require Gitolite::Conf::Load;
|
||||||
Gitolite::Conf::Load->import;
|
Gitolite::Conf::Load->import;
|
||||||
print "$_\n" for ( @{ list_groups() } );
|
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() } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue