gitolite/src/syntactic-sugar/keysubdirs-as-groups
Sitaram Chamarty 8714b77eae (perltidy)
2012-03-24 10:30:43 +05:30

32 lines
723 B
Plaintext
Executable file

# 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 {
my $lines = shift;
my @out = @{$lines};
unshift @out, groupnames();
return \@out;
}
sub groupnames {
my @out = ();
my %members = ();
for my $pk (`find ../keydir/ -name "*.pub"`) {
next unless $pk =~ m(.*/([^/]+)/([^/]+)\.pub$);
next if $1 eq 'keydir';
$members{$1} .= " $2";
}
for my $m ( sort keys %members ) {
push @out, "\@$m =" . $members{$m};
}
return @out;
}