# 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; }