From 34e0ecf20e6876a036a79966d6e8997420e76dbb Mon Sep 17 00:00:00 2001 From: Maggie Chen Date: Wed, 27 Sep 2023 20:35:10 +0000 Subject: [PATCH] Change from PresubmitError to PresubmitWarning for bad license We cannot distinguish if this is a moved third-party file. So just do warnings for a license header from a third-party company. Bug: 1462922 Change-Id: I78394dcccb9028bce6c535dfce625364dd29157b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4895337 Reviewed-by: Yiwei Zhang Reviewed-by: Bruce Dawson Commit-Queue: Maggie Chen --- presubmit_canned_checks.py | 16 ++++++++++------ tests/presubmit_unittest.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 5f0621341..9ca63391c 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -805,9 +805,11 @@ def CheckLicense(input_api, bad_files.append(f.LocalPath()) results = [] if bad_new_files: + # We can't distinguish between Google and thirty-party files, so this has to be a + # warning rather than an error. if license_re_param: - error_message = ('License on new files must match:\n\n%s\n' % - license_re_param) + warning_message = ('License on new files must match:\n\n%s\n' % + license_re_param) else: # Verbatim text that can be copy-pasted into new files (possibly # adjusting the leading comment delimiter). @@ -819,14 +821,16 @@ def CheckLicense(input_api, 'project': project_name, 'key_line': key_line, } - error_message = ( + warning_message = ( 'License on new files must be:\n\n%s\n' % new_license_text + '(adjusting the comment delimiter accordingly).\n\n' + 'If this is a moved file, then update the license but do not ' + - 'update the year.\n\n') - error_message += 'Found a bad license header in these new or moved files:' + 'update the year.\n\n' + + 'If this is a third-party file then ignore this warning.\n\n') + warning_message += 'Found a bad license header in these new or moved files:' results.append( - output_api.PresubmitError(error_message, items=bad_new_files)) + output_api.PresubmitPromptWarning(warning_message, + items=bad_new_files)) if wrong_year_new_files: # We can't distinguish between new and moved files, so this has to be a # warning rather than an error. diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index ec2dc8891..2388b9c9e 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2555,7 +2555,7 @@ the current line as well! self._LicenseCheck(text, license_text, False, - presubmit.OutputApi.PresubmitError, + presubmit.OutputApi.PresubmitPromptWarning, new_file=True) def _GetLicenseText(self, current_year):