'gitolite list-memberships' added

This commit is contained in:
Sitaram Chamarty 2012-03-08 17:00:27 +05:30
parent 4e81d3cfed
commit c9826eee07
2 changed files with 27 additions and 1 deletions

View file

@ -10,6 +10,7 @@ package Gitolite::Conf::Load;
list_groups list_groups
list_users list_users
list_repos list_repos
list_memberships
); );
use Exporter 'import'; use Exporter 'import';
@ -242,6 +243,23 @@ Usage: gitolite list-repos
return (sort_u(\@r)); return (sort_u(\@r));
} }
sub list_memberships {
die "
Usage: gitolite list-memberships <name>
- 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));
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
{ {

View file

@ -14,9 +14,12 @@ The following subcommands are available; they should all respond to '-h':
list-groups list all group names in conf list-groups list all group names in conf
list-users list all users/user groups in conf list-users list all users/user groups in conf
list-repos list all repos/repo groups in conf list-repos list all repos/repo groups in conf
list-memberships list all groups a name is a member of
Warnings: 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 =cut
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -71,5 +74,10 @@ sub args {
require Gitolite::Conf::Load; require Gitolite::Conf::Load;
Gitolite::Conf::Load->import; Gitolite::Conf::Load->import;
print "$_\n" for ( @{ list_repos() } ); 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() } );
} }
} }