From 352bf7e4444963556d9f34617b055885b5018110 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Tue, 11 Nov 2014 11:04:42 +0100 Subject: [PATCH] add ws-checks for commit messages Change-Id: I65e0ce4381b98b632dee740f1a3da546691f83ff Reviewed-by: Orgad Shaneh <orgads@gmail.com> --- git-hooks/sanitize-commit | 41 ++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 64f5172..8ea2f74 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -156,6 +156,26 @@ sub check_spelling() } } +my @style_fails = (); + +sub styleFail($) +{ + my $why = shift; + if ($gerrit_rest) { + complain_ln("$why", "style", -1); + } else { + push @style_fails, " $lineno: ".$why; + } +} + +sub complain_style() +{ + if (@style_fails) { + do_complain(1e9, "Style issues", "style", -1, @style_fails); + @style_fails = (); + } +} + sub check_apple_terminology() { if ($clike) { @@ -306,6 +326,9 @@ while (<MSG>) { check_spelling() if ($spell_check); check_apple_terminology(); + styleFail("Trailing whitespace") if (s/[ \t]+\r?\n$//); + styleFail("Space indent followed by a TAB character") if (/^ +\t/); + styleFail("TAB character in non-leading whitespace") if (/\S *\t/); } close MSG; printerr; @@ -324,6 +347,7 @@ if ($footer > 0 && !defined($cfg{footer})) { } complain_spelling(); +complain_style(); my $chunk = 0; my @addi = (); @@ -417,18 +441,6 @@ sub isExe($) return $type =~ /^(ELF|PE32) /; } -my @style_fails = (); - -sub styleFail($) -{ - my $why = shift; - if ($gerrit_rest) { - complain_ln("$why", "style", -1); - } else { - push @style_fails, " $lineno: ".$why; - } -} - my $no_copyright = 0; sub flushFile() @@ -437,10 +449,7 @@ sub flushFile() complain("Missing copyright header", "copyright"); } complain_spelling(); - if (@style_fails) { - do_complain(1e9, "Style issues", "style", -1, @style_fails); - @style_fails = (); - } + complain_style(); } my $merge; -- GitLab