info learned '-p' and pattern limiting.
'-p' is what gives you 'expand' now
This commit is contained in:
parent
5b5c02f226
commit
32494cfa0c
|
@ -2,19 +2,35 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
use lib $ENV{GL_BINDIR};
|
use lib $ENV{GL_BINDIR};
|
||||||
use Gitolite::Rc;
|
use Gitolite::Rc;
|
||||||
use Gitolite::Common;
|
use Gitolite::Common;
|
||||||
use Gitolite::Conf::Load;
|
use Gitolite::Conf::Load;
|
||||||
|
|
||||||
=for usage
|
=for usage
|
||||||
Usage: gitolite info
|
Usage: gitolite info [-p] [optional repo name pattern]
|
||||||
|
|
||||||
- list all repos/repo groups you can access
|
List all repos/repo groups you can access. By default, it shows you what the
|
||||||
- no options, no flags
|
conf file specified, which means group names and wild card patterns may show
|
||||||
|
up.
|
||||||
|
|
||||||
|
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.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
usage() if @ARGV;
|
my ( $help, $phy, $patt ) = ('') x 3;
|
||||||
|
GetOptions(
|
||||||
|
'p' => \$phy,
|
||||||
|
'h' => \$help,
|
||||||
|
) or usage();
|
||||||
|
|
||||||
|
usage() if @ARGV > 1;
|
||||||
|
$patt = shift || '.';
|
||||||
|
|
||||||
my $user = $ENV{GL_USER} or _die "GL_USER not set";
|
my $user = $ENV{GL_USER} or _die "GL_USER not set";
|
||||||
my $ref = 'any';
|
my $ref = 'any';
|
||||||
|
@ -22,22 +38,24 @@ my $ref = 'any';
|
||||||
print "hello $user, this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
|
print "hello $user, this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
|
||||||
|
|
||||||
my $lr = lister_dispatch('list-repos');
|
my $lr = lister_dispatch('list-repos');
|
||||||
my $lm = lister_dispatch('list-members');
|
|
||||||
|
|
||||||
for ( @{ $lr->() } ) {
|
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/;
|
||||||
my $perm = '';
|
my $perm = '';
|
||||||
for my $aa (qw(R W ^C)) {
|
for my $aa (qw(R W ^C)) {
|
||||||
my $ret = access( $_, $user, $aa, $ref );
|
my $ret = access( $repo, $user, $aa, $ref );
|
||||||
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
||||||
}
|
}
|
||||||
next unless $perm =~ /\S/;
|
$perm =~ s/\^//;
|
||||||
if (/^\@/) {
|
print "$perm\t$repo\n" if $perm =~ /\S/;
|
||||||
print "\n$perm\t$_\n";
|
|
||||||
for ( @{ $lm->($_) } ) {
|
|
||||||
print "$perm\t$_\n";
|
|
||||||
}
|
|
||||||
print "\n";
|
|
||||||
} else {
|
|
||||||
print "$perm\t$_\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
93
t/info.t
93
t/info.t
|
@ -9,7 +9,7 @@ use Gitolite::Test;
|
||||||
# the info command
|
# the info command
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
try 'plan 39';
|
try 'plan 83';
|
||||||
|
|
||||||
try "## info";
|
try "## info";
|
||||||
|
|
||||||
|
@ -32,27 +32,72 @@ try "
|
||||||
/Initialized.*empty.*t2.git/
|
/Initialized.*empty.*t2.git/
|
||||||
/Initialized.*empty.*t3.git/
|
/Initialized.*empty.*t3.git/
|
||||||
";
|
";
|
||||||
|
|
||||||
|
# GS == greeting string
|
||||||
|
try "DEF GS = /hello %1, this is gitolite/";
|
||||||
|
|
||||||
try "
|
try "
|
||||||
glt info u1; ok; /R W \t\@t1/
|
glt info u1; ok; GS u1
|
||||||
/R W \tt1/
|
/R W \t\@t1/
|
||||||
/R \tt2/
|
/R \tt2/
|
||||||
!/t3/
|
/R W \ttesting/
|
||||||
/R W \ttesting/
|
!/R W \tt3/
|
||||||
glt info u2; ok; /R \t\@t1/
|
glt info u2; ok; GS u2
|
||||||
/R \tt1/
|
/R \t\@t1/
|
||||||
/R W \tt2/
|
/R W \tt2/
|
||||||
!/t3/
|
/R W \ttesting/
|
||||||
/R W \ttesting/
|
!/R W \tt3/
|
||||||
glt info u3; ok; /R W \tt3/
|
glt info u3; ok; GS u3
|
||||||
!/\@t1/
|
/R W \tt3/
|
||||||
!/t[12]/
|
/R W \ttesting/
|
||||||
/R W \ttesting/
|
!/R \t\@t1/
|
||||||
glt info u4; ok; /R \tt3/
|
!/R W \tt2/
|
||||||
!/\@t1/
|
glt info u4; ok; GS u4
|
||||||
!/t[12]/
|
/R \tt3/
|
||||||
/R W \ttesting/
|
/R W \ttesting/
|
||||||
glt info u5; ok; !/t[123]/
|
!/R \t\@t1/
|
||||||
/R W \ttesting/
|
!/R W \tt2/
|
||||||
glt info u6; ok; !/t[123]/
|
glt info u5; ok; GS u5
|
||||||
/R W \ttesting/
|
/R W \ttesting/
|
||||||
" or die;
|
!/R \t\@t1/
|
||||||
|
!/R W \tt2/
|
||||||
|
!/R W \tt3/
|
||||||
|
glt info u6; ok; GS u6
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R \t\@t1/
|
||||||
|
!/R W \tt2/
|
||||||
|
!/R W \tt3/
|
||||||
|
";
|
||||||
|
|
||||||
|
try "
|
||||||
|
glt info u1 -p; ok; GS u1
|
||||||
|
/R W \tt1/
|
||||||
|
/R \tt2/
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R W \tt3/
|
||||||
|
glt info u2 -p; ok; GS u2
|
||||||
|
/R \tt1/
|
||||||
|
/R W \tt2/
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R W \tt3/
|
||||||
|
glt info u3 -p; ok; GS u3
|
||||||
|
/R W \tt3/
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R \tt1/
|
||||||
|
!/R W \tt2/
|
||||||
|
glt info u4 -p; ok; GS u4
|
||||||
|
/R \tt3/
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R \tt1/
|
||||||
|
!/R W \tt2/
|
||||||
|
glt info u5 -p; ok; GS u5
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R \tt1/
|
||||||
|
!/R W \tt2/
|
||||||
|
!/R W \tt3/
|
||||||
|
glt info u6 -p; ok; GS u6
|
||||||
|
/R W \ttesting/
|
||||||
|
!/R \tt1/
|
||||||
|
!/R W \tt2/
|
||||||
|
!/R W \tt3/
|
||||||
|
";
|
||||||
|
|
Loading…
Reference in a new issue