From d969c5246f12e7f458578ae308f7364ef780c56d Mon Sep 17 00:00:00 2001 From: Orgad Shaneh <orgad.shaneh@audiocodes.com> Date: Tue, 14 May 2013 15:28:58 +0300 Subject: [PATCH] Sanity: Add copyright test Change-Id: Ic15a8917b8b09d45f608123eab83b08079b837d6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> --- git-hooks/sanitize-commit | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 4863902..11e48cf 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -323,8 +323,13 @@ sub styleFail($) push @style_fails, $lineno.": ".$why; } +my $no_copyright = 0; + sub flushFile() { + if ($no_copyright) { + &complain("Missing copyright header", "copyright"); + } if (@style_fails) { &complain("Style issues", "style", -1); for my $sf (@style_fails) { @@ -357,8 +362,11 @@ while (<DIFF>) { } next; } - if ($lineno < 50 && $check_gen) { - if (/All changes made in this file will be lost|This file is automatically generated|DO NOT EDIT|DO NOT delete this file|[Gg]enerated by|uicgenerated|produced by gperf/) { + if ($lineno < 50) { + if ($no_copyright && /Copyright/) { + $no_copyright = 0; + } + if ($check_gen && /All changes made in this file will be lost|This file is automatically generated|DO NOT EDIT|DO NOT delete this file|[Gg]enerated by|uicgenerated|produced by gperf/) { &complain("Adding generated file", "generated") if ($new_file && !defined($cfg{generated})); $ws_check = 0; $check_gen = 0; @@ -455,6 +463,7 @@ while (<DIFF>) { $conflict_fail = defined($cfg{conflict}); $braces = 0; $check_gen = 0; + $no_copyright = 0; next; } if ($maybe_bin && /^Binary files /) { @@ -496,6 +505,7 @@ while (<DIFF>) { } $size = 0; $new_file = 1; + $no_copyright = $issrc; } elsif ($size > 20000 && !$issrc && !defined($cfg{size})) { my $old_size = 0; for my $old_tree (split(/,/, $old_trees)) { -- GitLab