#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use lib $ENV{GL_LIBDIR}; use Gitolite::Rc; use Gitolite::Common; use Gitolite::Conf::Load; =for args Usage: gitolite info [-lc] [] List all repos/repo groups you can access. '-lc' lists creators as an additional field at the end. 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 # these two are globals my ( $lc, $patt ) = args(); print_version(); print_patterns(); # repos he can create for himself print_phy_repos(); # repos already created print "\n$rc{SITE_INFO}\n" if $rc{SITE_INFO}; # ---------------------------------------------------------------------- sub args { my ( $lc, $patt ) = ( '', '' ); my $help = ''; GetOptions( 'lc' => \$lc, 'h' => \$help, ) or usage(); usage() if @ARGV > 1 or $help; $patt = shift @ARGV || '.'; return ( $lc, $patt ); } sub print_version { chomp( my $hn = `hostname -s` ); my $gv = substr( `git --version`, 12 ); $ENV{GL_USER} or _die "GL_USER not set"; print "hello $ENV{GL_USER}, this is $ENV{USER}\@$hn running gitolite3 " . version() . " on git $gv\n"; } sub print_patterns { my ( $repos, @aa ); # find repo patterns only, call them with ^C flag included @$repos = grep { !/$REPONAME_PATT/ } @{ lister_dispatch('list-repos')->() }; @aa = qw(R W ^C); listem( $repos, '', @aa ); # but squelch the 'lc' flag for these } sub print_phy_repos { my ( $repos, @aa ); # now get the actual repos and get R or W only _chdir( $rc{GL_REPO_BASE} ); $repos = list_phy_repos(1); @aa = qw(R W); listem( $repos, $lc, @aa ); } sub listem { my ( $repos, $lc, @aa ) = @_; 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, $ENV{GL_USER}, $aa, 'any' ); $perm .= ( $ret =~ /DENIED/ ? " " : " $aa" ); } $perm =~ s/\^//; next unless $perm =~ /\S/; print "$perm\t$repo"; print "\t$creator" if $lc; print "\n"; } }