summaryrefslogtreecommitdiffstats
path: root/src/syntactic-sugar/refex-expr
blob: f9e7706b6dc69c74f6624ee2db28d80f578579e0 (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
# vim: syn=perl:

# "sugar script" (syntactic sugar helper) for gitolite3
# ----------------------------------------------------------------------
# see src/VREF/refex-expr for instructions and WARNINGS!

my $perm = qr(-|R|RW\+?C?D?M?);

my $seq = 1;

sub sugar_script {
    my $lines = shift;

    # my @out  = ();
    for my $l (@$lines) {
        push @out, $l;

        # quick check
        next unless $l =~ /^($perm) /;
        # more detailed check
        next unless $l =~ /^($perm) (\S.*) = (\S.*)$/;
        my ( $perm, $refexes, $users ) = ( $1, $2, $3 );
        next unless $refexes =~ / (and|not|or|xor|\+|-|==|-lt|-gt|-eq|-le|-ge|-ne) /;

        print STDERR ">>>> $l\n";
        pop @out;    # we need to replace that last line

        push @out, "option refex-expr.sugar$seq = $refexes";
        push @out, "$perm VREF/refex-expr/sugar$seq = $users";

        $seq++;
    }

    return \@out;
}