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 <dpranke@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/86/2910486/2
Bruce Dawson 4 years ago committed by LUCI CQ
parent da8a67b497
commit b0bfaf1b3d

@ -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):

Loading…
Cancel
Save