From b0bfaf1b3d8a67e390e3b501e983a0a46e89327b Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Fri, 21 May 2021 18:03:53 +0000 Subject: [PATCH] Strip Windows line endings when checking licenses The CheckLicense presubmit is supposed to check for correct licenses, not for correct line endings. By reading the input file in binary mode it implictly does both, leading to confusing error messages. This is exacerbated by bugs in the line ending checks which are being addressed separately. This change will avoid false positives on files that have Windows line endings. Change-Id: I2ff8632f273ec4896cb4918c386e0d1c12e72935 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2910486 Reviewed-by: Dirk Pranke Commit-Queue: Bruce Dawson --- presubmit_canned_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 076b4ec9f..ed0b3af83 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -579,7 +579,7 @@ def CheckLicense(input_api, output_api, license_re=None, project_name=None, license_re = input_api.re.compile(license_re, input_api.re.MULTILINE) bad_files = [] for f in input_api.AffectedSourceFiles(source_file_filter): - contents = input_api.ReadFile(f, 'rb') + contents = input_api.ReadFile(f, 'r') if accept_empty_files and not contents: continue if not license_re.search(contents):