diff options
author | Daniel Smith <daniel.smith@qt.io> | 2024-01-23 10:41:03 +0100 |
---|---|---|
committer | Daniel Smith <daniel.smith@qt.io> | 2024-01-29 09:17:31 +0000 |
commit | 130826c46e393ce5a07140533cf5c75b6d583836 (patch) | |
tree | 3ad7d98d3bd88502346e6d6529806773a1ba3aaa | |
parent | 62c866e68f82d0c940c7c4ee5faff3e517b82ecd (diff) |
Perform generated file checks on a wider set of file types
Fixup for 62c866e68f82d0c940c7c4ee5faff3e517b82ecd.
Simply adding the newly generated keywords did not suffice
for detecting headers generated by Sol, as they use the .hpp
extension. This caused them to fall under a condition that
didn't set the $check_gen flag. This issue could also affect
other file types, so a more generic check is necessary.
Change-Id: I3422d14f1cf35c512c48d7e12e8c5dbfaf1d6026
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Daniel Smith <daniel.smith@qt.io>
-rwxr-xr-x | git-hooks/sanitize-commit | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index c853f70..344518b 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -835,18 +835,23 @@ while (<DIFF>) { if (/^\+\+\+ /) { # This indicates a text file; binary files have "Binary files ... and ... differ" instead. $maybe_bin = 0; - if ($file =~ /(~|\.(old|bak))$/i) { - complain("Adding backup file", "backup") if ($new_file && !defined($cfg{backup})); - $ws_check = 0; - } elsif ($file =~ m,^tests/.*/(perf|test)?data[/_-],) { - $ws_check = $eof_check = $apple_check = $no_copyright = 0; - } elsif ($file =~ /\.(prl|la|pc|ilk)$/i) { + + if ($file =~ /\.(prl|la|pc|ilk)$/i) { complain("Adding build artifact", "generated") if ($new_file && !defined($cfg{generated})); $ws_check = 0; - } elsif ($file =~ /\.(hpp|ch|h\+\+|hh|hxx)$/i) { - complain("Adding header file with a non-.h extension", "extension") if ($new_file && !$foreign && !defined($cfg{extension})); - } elsif ($file !~ /\.qmltypes$/i) { - $check_gen = 1; + } else { + if ($file !~ /\.qmltypes$/i) { + $check_gen = 1; + } + if ($file =~ m,^tests/.*/(perf|test)?data[/_-],) { + $ws_check = $eof_check = $apple_check = $no_copyright = 0; + # Additional logic for test data goes here... + } elsif ($file =~ /(~|\.(old|bak))$/i) { + complain("Adding backup file", "backup") if ($new_file && !defined($cfg{backup})); + $ws_check = 0; + } elsif ($file =~ /\.(hpp|ch|h\+\+|hh|hxx)$/i) { + complain("Adding header file with a non-.h extension", "extension") if ($new_file && !$foreign && !defined($cfg{extension})); + } } next; } |