From 3b563091836025e39b6b44ec0fbdde2d7ba36024 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 15 Jun 2021 01:17:42 +0000 Subject: [PATCH] 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 Commit-Queue: Bruce Dawson --- presubmit_canned_checks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index f64219bae5..74d5d16e6d 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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,