"memberships()" can now deal with most everything except roles
This commit is contained in:
parent
f21d17e086
commit
a014d2ffd5
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue