aboutsummaryrefslogtreecommitdiffstats
path: root/commit-check
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-03-05 00:17:35 +0100
committerGravatar Tom Willemse2014-03-05 00:17:35 +0100
commita4279c3b6bd18b2aaeb9359f91c4f207d6f3e425 (patch)
treedbb22da4a638bddc7735d943a845e1916d5bab93 /commit-check
downloadcommit-check-a4279c3b6bd18b2aaeb9359f91c4f207d6f3e425.tar.gz
commit-check-a4279c3b6bd18b2aaeb9359f91c4f207d6f3e425.zip
Initial commit
Diffstat (limited to 'commit-check')
-rwxr-xr-xcommit-check30
1 files changed, 30 insertions, 0 deletions
diff --git a/commit-check b/commit-check
new file mode 100755
index 0000000..6543633
--- /dev/null
+++ b/commit-check
@@ -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;