diff --git a/Gitolite/Conf/Load.pm b/Gitolite/Conf/Load.pm index 130850a..cc88225 100644 --- a/Gitolite/Conf/Load.pm +++ b/Gitolite/Conf/Load.pm @@ -10,6 +10,7 @@ package Gitolite::Conf::Load; list_groups list_users list_repos + list_memberships ); use Exporter 'import'; @@ -242,6 +243,23 @@ Usage: gitolite list-repos return (sort_u(\@r)); } +sub list_memberships { + + die " +Usage: gitolite list-memberships + + - list all groups a name is a member of + - takes one user/repo name + +" if @ARGV and $ARGV[0] eq '-h' or not @ARGV and not @_; + + my $name = ( @_ ? shift @_ : shift @ARGV ); + + load_common(); + my @m = memberships($name); + return (sort_u(\@m)); +} + # ---------------------------------------------------------------------- { diff --git a/gitolite b/gitolite index 6adc347..5d5f3dd 100755 --- a/gitolite +++ b/gitolite @@ -14,9 +14,12 @@ The following subcommands are available; they should all respond to '-h': list-groups list all group names in conf list-users list all users/user groups in conf list-repos list all repos/repo groups in conf + list-memberships list all groups a name is a member of Warnings: - - list-users is disk bound and could take a while on sites with thousands of repos + - list-users is disk bound and could take a while on sites with 1000s of repos + - list-memberships does not check if the name is known; unknown names come + back with 2 answers: the name itself and '@all' =cut # ---------------------------------------------------------------------- @@ -71,5 +74,10 @@ sub args { require Gitolite::Conf::Load; Gitolite::Conf::Load->import; print "$_\n" for ( @{ list_repos() } ); + } elsif ( $command eq 'list-memberships' ) { + shift @ARGV; + require Gitolite::Conf::Load; + Gitolite::Conf::Load->import; + print "$_\n" for ( @{ list_memberships() } ); } }