'info' learns '-lc' option (and load.pm exports creator())

This commit is contained in:
Sitaram Chamarty 2012-03-20 07:19:07 +05:30
parent 9f1e360ef3
commit 2e1f840f13
2 changed files with 25 additions and 7 deletions

View file

@ -9,6 +9,7 @@ package Gitolite::Conf::Load;
git_config git_config
option option
repo_missing repo_missing
creator
vrefs vrefs
lister_dispatch lister_dispatch
); );

View file

@ -10,25 +10,37 @@ use Gitolite::Common;
use Gitolite::Conf::Load; use Gitolite::Conf::Load;
=for usage =for usage
Usage: gitolite info [-p] [optional repo name pattern] Usage: gitolite info [-p [-lc] [<repo name pattern>]
List all repos/repo groups you can access. By default, it shows you what the 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 conf file specified, which means group names and wild card patterns may show
up. up. Example, if the conf file looked like this:
With '-p' it looks at actual (physical) repos instead. @oss = git gitolite linux
repo @oss
RW+ = YourName
then running 'ssh git@host info' will only show you '@oss'.
'-p' looks at actual (physical) repos instead; in our example this will show
you git, gitolite, and linux.
'-lc' lists creators as an additional field at the end; this option is only
available with '-p'.
The optional pattern is an unanchored regex that will limit the repos 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 searched, in both cases. It might speed up things a little if you have more
than a few thousand repos. than a few thousand repos.
=cut =cut
my ( $help, $phy, $patt ) = ('') x 3; my ( $help, $phy, $lc, $patt ) = ('') x 4;
GetOptions( GetOptions(
'lc' => \$lc,
'p' => \$phy, 'p' => \$phy,
'h' => \$help, 'h' => \$help,
) or usage(); ) or usage();
usage("'-lc' requires '-p'") if $lc and not $phy;
usage() if @ARGV > 1 or $help; usage() if @ARGV > 1 or $help;
$patt = shift || '.'; $patt = shift || '.';
@ -49,13 +61,18 @@ if ($phy) {
$repos = $lr->(); $repos = $lr->();
} }
my $creator = '';
for my $repo (@$repos) { for my $repo (@$repos) {
next unless $repo =~ /$patt/; next unless $repo =~ /$patt/;
my $perm = ''; my $perm = '';
$creator = creator($repo) if $lc;
for my $aa (qw(R W ^C)) { for my $aa (qw(R W ^C)) {
my $ret = access( $repo, $user, $aa, $ref ); my $ret = access( $repo, $user, $aa, $ref );
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" ); $perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
} }
$perm =~ s/\^//; $perm =~ s/\^//;
print "$perm\t$repo\n" if $perm =~ /\S/; next unless $perm =~ /\S/;
print "$perm\t$repo";
print "\t$creator" if $lc;
print "\n";
} }