2012-03-15 00:58:56 +01:00
|
|
|
# vim: syn=perl:
|
|
|
|
|
|
|
|
# "sugar script" (syntactic sugar helper) for gitolite3
|
|
|
|
|
|
|
|
# Enabling this script in the rc file allows you to use subdirectories in
|
|
|
|
# keydir as group names. The last component other than keydir itself will be
|
|
|
|
# taken as the group name.
|
|
|
|
|
|
|
|
sub sugar_script {
|
2012-03-18 16:11:02 +01:00
|
|
|
Gitolite::Common::trace( 2, "running 'keysubdirs-as-groups' sugar script..." );
|
2012-03-15 00:58:56 +01:00
|
|
|
my $lines = shift;
|
|
|
|
|
2012-03-15 15:34:30 +01:00
|
|
|
my @out = @{$lines};
|
2012-03-15 00:58:56 +01:00
|
|
|
unshift @out, groupnames();
|
|
|
|
|
|
|
|
return \@out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub groupnames {
|
2012-03-15 15:34:30 +01:00
|
|
|
my @out = ();
|
2012-03-15 00:58:56 +01:00
|
|
|
my %members = ();
|
|
|
|
for my $pk (`find ../keydir/ -name "*.pub"`) {
|
|
|
|
next unless $pk =~ m(.*/([^/]+)/([^/]+)\.pub$);
|
|
|
|
next if $1 eq 'keydir';
|
|
|
|
$members{$1} .= " $2";
|
|
|
|
}
|
2012-03-15 15:34:30 +01:00
|
|
|
for my $m ( sort keys %members ) {
|
2012-03-15 00:58:56 +01:00
|
|
|
push @out, "\@$m =" . $members{$m};
|
|
|
|
}
|
|
|
|
|
|
|
|
return @out;
|
|
|
|
}
|