diff --git a/Gitolite/Conf/Load.pm b/Gitolite/Conf/Load.pm index cc88225..9367296 100644 --- a/Gitolite/Conf/Load.pm +++ b/Gitolite/Conf/Load.pm @@ -11,6 +11,7 @@ package Gitolite::Conf::Load; list_users list_repos list_memberships + list_members ); use Exporter 'import'; @@ -260,6 +261,30 @@ Usage: gitolite list-memberships return (sort_u(\@m)); } +sub list_members { + + die " +Usage: gitolite list-members + + - list all members of a group + - takes one group name + +" if @ARGV and $ARGV[0] eq '-h' or not @ARGV and not @_; + + my $name = ( @_ ? shift @_ : shift @ARGV ); + + load_common(); + + my @m = (); + while (my ($k, $v) = each ( %groups )) { + for my $g ( @{ $v } ) { + push @m, $k if $g eq $name; + } + } + + return (sort_u(\@m)); +} + # ---------------------------------------------------------------------- { diff --git a/gitolite b/gitolite index 5d5f3dd..dc7fb0e 100755 --- a/gitolite +++ b/gitolite @@ -15,6 +15,7 @@ The following subcommands are available; they should all respond to '-h': 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 + list-members list all members of a group Warnings: - list-users is disk bound and could take a while on sites with 1000s of repos @@ -79,5 +80,10 @@ sub args { require Gitolite::Conf::Load; Gitolite::Conf::Load->import; print "$_\n" for ( @{ list_memberships() } ); + } elsif ( $command eq 'list-members' ) { + shift @ARGV; + require Gitolite::Conf::Load; + Gitolite::Conf::Load->import; + print "$_\n" for ( @{ list_members() } ); } }