From 5ebb981efabd201b2bffde1edf88d6f19ff806e7 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Thu, 15 Mar 2012 05:28:56 +0530 Subject: [PATCH] new sugar -- keysubdirs as groups. TODO: add appropriate commented entry to Gitolite::Rc.pm also --- src/syntactic-sugar/keysubdirs-as-groups | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 src/syntactic-sugar/keysubdirs-as-groups diff --git a/src/syntactic-sugar/keysubdirs-as-groups b/src/syntactic-sugar/keysubdirs-as-groups new file mode 100755 index 0000000..d16dc78 --- /dev/null +++ b/src/syntactic-sugar/keysubdirs-as-groups @@ -0,0 +1,31 @@ +# 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; +}