Initial commit

This commit is contained in:
Tom Willemse 2014-03-05 00:17:35 +01:00
commit a4279c3b6b
4 changed files with 42 additions and 0 deletions

30
commit-check Executable file
View file

@ -0,0 +1,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;

3
test-fail-barely.txt Normal file
View file

@ -0,0 +1,3 @@
This line is the commit subject, it be 50 char long
This is a regular line. It really should be 72 characters long. Let's see

4
test-fail-miserably.txt Normal file
View file

@ -0,0 +1,4 @@
# This is a comment and should not be checked at all. It can be as long as it wants to be.
this, on the other hand, is not a comment. It is also the first line and should not be longer than 50 characters.
This line should be empty
This line is a regular text line. It should not be longer than 80 characters. We should check that.

5
test-pass.txt Normal file
View file

@ -0,0 +1,5 @@
# Since this is a comment it really doesn't matter how long it is, so anything should be fine here.
This line is the commit subject, it be 50 chr long
This is a regular line. It really should be 72 characters long. Lets see