From 545e13f4c100eab9c31fdd1a2308f65b4792c0e9 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 24 Mar 2020 22:29:11 +0100 Subject: [PATCH] Check that Windows files have Windows line endings Signed-off-by: Gilles Peskine --- tests/scripts/check-files.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/scripts/check-files.py b/tests/scripts/check-files.py index 135a3b3928..e4a365f163 100755 --- a/tests/scripts/check-files.py +++ b/tests/scripts/check-files.py @@ -139,6 +139,18 @@ class UnixLineEndingIssueTracker(LineIssueTracker): return b"\r" in line +class WindowsLineEndingIssueTracker(LineIssueTracker): + """Track files with non-Windows line endings (i.e. files without CR).""" + + heading = "Non-Windows line endings:" + + def should_check_file(self, filepath): + return is_windows_file(filepath) + + def issue_with_line(self, line, _filepath): + return not line.endswith(b"\r\n") + + class TrailingWhitespaceIssueTracker(LineIssueTracker): """Track lines with trailing whitespace.""" @@ -222,6 +234,7 @@ class IntegrityChecker(object): EndOfFileNewlineIssueTracker(), Utf8BomIssueTracker(), UnixLineEndingIssueTracker(), + WindowsLineEndingIssueTracker(), TrailingWhitespaceIssueTracker(), TabIssueTracker(), MergeArtifactIssueTracker(),