summaryrefslogtreecommitdiffstats
path: root/src/syntactic-sugar/keysubdirs-as-groups
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:55:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:55:51 +0000
commit7685305e1f82212323ec32a321b1f5c623751b6c (patch)
treea1af617672e26aee4c1031a3aa83e8ff08f6a0a5 /src/syntactic-sugar/keysubdirs-as-groups
parentInitial commit. (diff)
downloadgitolite3-7685305e1f82212323ec32a321b1f5c623751b6c.tar.xz
gitolite3-7685305e1f82212323ec32a321b1f5c623751b6c.zip
Adding upstream version 3.6.12.upstream/3.6.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/syntactic-sugar/keysubdirs-as-groups')
-rw-r--r--src/syntactic-sugar/keysubdirs-as-groups32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/syntactic-sugar/keysubdirs-as-groups b/src/syntactic-sugar/keysubdirs-as-groups
new file mode 100644
index 0000000..0a3a9ae
--- /dev/null
+++ b/src/syntactic-sugar/keysubdirs-as-groups
@@ -0,0 +1,32 @@
+# 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 {
+ Gitolite::Common::trace( 2, "running 'keysubdirs-as-groups' 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;
+}