From a014d2ffd5f7cc1ca1e7f80735378dae409913e4 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 16 Mar 2012 21:39:26 +0530 Subject: [PATCH] "memberships()" can now deal with most everything except roles --- src/Gitolite/Conf/Load.pm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Gitolite/Conf/Load.pm b/src/Gitolite/Conf/Load.pm index 0e5bc4e..939744c 100644 --- a/src/Gitolite/Conf/Load.pm +++ b/src/Gitolite/Conf/Load.pm @@ -111,7 +111,7 @@ sub git_config { # if it has an entry in %configs grep { $configs{$_} } # for each "repo" that represents us - memberships($repo); + memberships('repo', $repo); # %configs looks like this (for each 'foo' that is in memberships()) # 'foo' => [ [ 6, 'foo.bar', 'repo' ], [ 7, 'foodbar', 'repoD' ], [ 8, 'foo.czar', 'jule' ] ], @@ -193,8 +193,8 @@ sub load_1 { my @rules = (); - my @repos = memberships($repo); - my @users = memberships($user); + my @repos = memberships('repo', $repo); + my @users = memberships('user', $user); trace( 3, "memberships: " . scalar(@repos) . " repos and " . scalar(@users) . " users found" ); for my $r (@repos) { @@ -224,11 +224,36 @@ sub load_1 { } sub memberships { + my $type = shift; my $item = shift; + my $item2 = ''; my @ret = ( $item, '@all' ); - push @ret, @{ $groups{$item} } if $groups{$item}; + if ($type eq 'repo') { + my $f = "$rc{GL_REPO_BASE}/$item.git/gl-creator"; + if (-f $f) { + my $creator; + chomp($creator = slurp($f)); + ($item2 = $item) =~ s(/$creator/)(/CREATOR/); + $item2 = '' if $item2 eq $item; # no change + } + for my $i (keys %repos) { + if ($item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ )) { + push @ret, $i; + } + } + + } + + for my $i (keys %groups) { + if ($item eq $i or $item =~ /^$i$/ or $item2 and ( $item2 eq $i or $item2 =~ /^$i$/ )) { + push @ret, @{ $groups{$i} }; + } + } + + @ret = @{ sort_u(\@ret) }; + dbg(\@ret); return @ret; } @@ -324,7 +349,7 @@ sub list_memberships { my $name = shift; load_common(); - my @m = memberships($name); + my @m = memberships('', $name); return ( sort_u( \@m ) ); }