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 <yiwzhang@google.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
changes/37/4895337/4
Maggie Chen 2 years ago committed by LUCI CQ
parent 853b29f65d
commit 34e0ecf20e

@ -805,8 +805,10 @@ def CheckLicense(input_api,
bad_files.append(f.LocalPath()) bad_files.append(f.LocalPath())
results = [] results = []
if bad_new_files: 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: if license_re_param:
error_message = ('License on new files must match:\n\n%s\n' % warning_message = ('License on new files must match:\n\n%s\n' %
license_re_param) license_re_param)
else: else:
# Verbatim text that can be copy-pasted into new files (possibly # Verbatim text that can be copy-pasted into new files (possibly
@ -819,14 +821,16 @@ def CheckLicense(input_api,
'project': project_name, 'project': project_name,
'key_line': key_line, 'key_line': key_line,
} }
error_message = ( warning_message = (
'License on new files must be:\n\n%s\n' % new_license_text + 'License on new files must be:\n\n%s\n' % new_license_text +
'(adjusting the comment delimiter accordingly).\n\n' + '(adjusting the comment delimiter accordingly).\n\n' +
'If this is a moved file, then update the license but do not ' + 'If this is a moved file, then update the license but do not ' +
'update the year.\n\n') 'update the year.\n\n' +
error_message += 'Found a bad license header in these new or moved files:' '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( 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: if wrong_year_new_files:
# We can't distinguish between new and moved files, so this has to be a # We can't distinguish between new and moved files, so this has to be a
# warning rather than an error. # warning rather than an error.

@ -2555,7 +2555,7 @@ the current line as well!
self._LicenseCheck(text, self._LicenseCheck(text,
license_text, license_text,
False, False,
presubmit.OutputApi.PresubmitError, presubmit.OutputApi.PresubmitPromptWarning,
new_file=True) new_file=True)
def _GetLicenseText(self, current_year): def _GetLicenseText(self, current_year):

Loading…
Cancel
Save