2012-03-12 16:24:30 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2012-03-19 16:31:08 +01:00
|
|
|
use Getopt::Long;
|
|
|
|
|
2012-03-12 16:24:30 +01:00
|
|
|
use lib $ENV{GL_BINDIR};
|
|
|
|
use Gitolite::Rc;
|
|
|
|
use Gitolite::Common;
|
|
|
|
use Gitolite::Conf::Load;
|
|
|
|
|
|
|
|
=for usage
|
2012-03-19 16:31:08 +01:00
|
|
|
Usage: gitolite info [-p] [optional repo name pattern]
|
|
|
|
|
|
|
|
List all repos/repo groups you can access. By default, it shows you what the
|
|
|
|
conf file specified, which means group names and wild card patterns may show
|
|
|
|
up.
|
2012-03-12 16:24:30 +01:00
|
|
|
|
2012-03-19 16:31:08 +01:00
|
|
|
With '-p' it looks at actual (physical) repos instead.
|
|
|
|
|
|
|
|
The optional pattern is an unanchored regex that will limit the repos
|
|
|
|
searched, in both cases. It might speed up things a little if you have more
|
|
|
|
than a few thousand repos.
|
2012-03-12 16:24:30 +01:00
|
|
|
=cut
|
|
|
|
|
2012-03-19 16:31:08 +01:00
|
|
|
my ( $help, $phy, $patt ) = ('') x 3;
|
|
|
|
GetOptions(
|
|
|
|
'p' => \$phy,
|
|
|
|
'h' => \$help,
|
|
|
|
) or usage();
|
|
|
|
|
|
|
|
usage() if @ARGV > 1;
|
|
|
|
$patt = shift || '.';
|
2012-03-12 16:24:30 +01:00
|
|
|
|
|
|
|
my $user = $ENV{GL_USER} or _die "GL_USER not set";
|
|
|
|
my $ref = 'any';
|
|
|
|
|
2012-03-15 15:34:30 +01:00
|
|
|
print "hello $user, this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
|
2012-03-15 14:44:40 +01:00
|
|
|
|
2012-03-15 01:37:41 +01:00
|
|
|
my $lr = lister_dispatch('list-repos');
|
2012-03-12 16:24:30 +01:00
|
|
|
|
2012-03-19 16:31:08 +01:00
|
|
|
my $perm;
|
|
|
|
my $repos;
|
|
|
|
|
|
|
|
if ($phy) {
|
|
|
|
_chdir( $rc{GL_REPO_BASE} );
|
|
|
|
$repos = list_phy_repos(1);
|
|
|
|
} else {
|
|
|
|
$repos = $lr->();
|
|
|
|
}
|
|
|
|
|
|
|
|
for my $repo (@$repos) {
|
|
|
|
next unless $repo =~ /$patt/;
|
2012-03-12 16:24:30 +01:00
|
|
|
my $perm = '';
|
|
|
|
for my $aa (qw(R W ^C)) {
|
2012-03-19 16:31:08 +01:00
|
|
|
my $ret = access( $repo, $user, $aa, $ref );
|
2012-03-12 16:24:30 +01:00
|
|
|
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
|
|
|
}
|
2012-03-19 16:31:08 +01:00
|
|
|
$perm =~ s/\^//;
|
|
|
|
print "$perm\t$repo\n" if $perm =~ /\S/;
|
2012-03-12 16:24:30 +01:00
|
|
|
}
|