gitolite/src/commands/info
Sitaram Chamarty 0748b1225b external programs can get settings from rc; see below
non-core programs can get their settings from the rc file also.
cpu-time is a perl example and desc is a shell example.

(info is not a good example because it does not use "Gitolite::Easy")
2012-03-24 10:30:46 +05:30

85 lines
2 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use lib $ENV{GL_BINDIR};
use Gitolite::Rc;
use Gitolite::Common;
use Gitolite::Conf::Load;
=for usage
Usage: gitolite info [-p [-lc] [<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. Example, if the conf file looked like this:
@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
searched, in both cases. It might speed up things a little if you have more
than a few thousand repos.
=cut
my ( $help, $phy, $lc, $patt ) = ('') x 4;
GetOptions(
'lc' => \$lc,
'p' => \$phy,
'h' => \$help,
) or usage();
usage("'-lc' requires '-p'") if $lc and not $phy;
usage() if @ARGV > 1 or $help;
$patt = shift || '.';
my $user = $ENV{GL_USER} or _die "GL_USER not set";
my $ref = 'any';
print "hello $user, this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
my $lr = lister_dispatch('list-repos');
my $perm;
my $repos;
my @aa;
if ($phy) {
_chdir( $rc{GL_REPO_BASE} );
$repos = list_phy_repos(1);
@aa = qw(R W);
} else {
$repos = $lr->();
@aa = qw(R W ^C);
}
my $creator = '';
for my $repo (@$repos) {
next unless $repo =~ /$patt/;
my $perm = '';
$creator = creator($repo) if $lc;
for my $aa (@aa) {
my $ret = access( $repo, $user, $aa, $ref );
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
}
$perm =~ s/\^//;
next unless $perm =~ /\S/;
print "$perm\t$repo";
print "\t$creator" if $lc;
print "\n";
}
print "\n$rc{SITE_INFO}\n" if $rc{SITE_INFO};