blob: d63475ff7139c9d1d1ae33d379769c0b2b0e9334 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# vim: syn=perl:
# "sugar script" (syntactic sugar helper) for gitolite3
# Enabling this script in the rc file allows you to use back-slash escaped
# continuation lines, like in C or shell etc.
# This script also serves as an example "sugar script" if you want to write
# your own (and maybe send them to me). A "sugar script" in gitolite will be
# executed via a perl 'do' and is expected to contain one function called
# 'sugar_script'. This function should take a listref and return a listref.
# Each item in the list is one line. There are NO newlines; g3 kills them off
# fairly early in the process.
# If you're not familiar with perl please do not try this. Ask me to write
# you a sugar script instead.
sub sugar_script {
my $lines = shift;
my @out = ();
my $keep = '';
for my $l (@$lines) {
# skip RULE_INFO lines if in continuation mode
next if $keep and $l =~ /^ *#/;
if ( $l =~ s/\\$// ) {
$keep .= $l;
} else {
$l = $keep . $l if $keep;
$keep = '';
push @out, $l;
}
}
return \@out;
}
|