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,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.

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

Loading…
Cancel
Save