aboutsummaryrefslogtreecommitdiffstats
path: root/commit-check
blob: 6543633a9e7e2d466334537cef492a1139c1a124 (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
#!/usr/bin/env perl
use strict;
use warnings;

my $lineno = 0;
my $status = 0;

sub err {
    my ($msg) = @_;

    print STDERR "Error on line $lineno (actual line $.): ". $msg ."\n";
    $status = 1;
}

while (<>) {
    next if /^#/;                 # Discard comments
    next if $lineno == 0 && /^$/; # Discard leading empty lines
    $lineno++;                    # Start at 1, so increment first

    if ($lineno == 1) {
        err "Not capitalized" if /^[^[:upper:]]/;
        err "Longer than 50 characters" if /^.{51,}/;
        next;
    }

    err "Should be empty" if $lineno == 2 && /.+/;
    err "Longer than 80 characters" if /^.{73,}/;
}

exit $status;