Ignore \r characters in CheckLicense

If you copy\paste a license header in such a way that \r\n line endings
are used (I have done this) then CheckLicense would fail. This is quite
confusing because the license looks perfect in most text editors. This
change tells CheckLicense to treat \r\n line endings as equivalent to \n
and let CheckForWindowsLineEndings do its job of warning about the \r\n
line endings. This avoids confusing presubmit messages.

Bug: 801033
Change-Id: I37fa4a6d9cd0f1a4dcce1267175f4b8fd298b906
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2951788
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/88/2951788/3
Bruce Dawson 4 years ago committed by LUCI CQ
parent cdd52af784
commit 3b56309183

@ -567,10 +567,10 @@ def CheckLicense(input_api, output_api, license_re=None, project_name=None,
# The (c) is deprecated, but tolerate it until it's removed from all files.
license_re = license_re or (
r'.*? Copyright (\(c\) )?%(year)s The %(project)s Authors\. '
r'All rights reserved\.\n'
r'All rights reserved\.\r?\n'
r'.*? Use of this source code is governed by a BSD-style license that '
r'can be\n'
r'.*? found in the LICENSE file\.(?: \*/)?\n'
r'can be\r?\n'
r'.*? found in the LICENSE file\.(?: \*/)?\r?\n'
) % {
'year': years_re,
'project': project_name,

Loading…
Cancel
Save