Commit 1dc66e16 authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

presubmit: Add should_continue and more_cc to presubmit json output.

Also, rename --all-files to --all_files to be consistent with other
options, and remove reviewers, since it's never set in presubmit_support.

Bug: 1042324
Change-Id: I34fa3162c56e39bcdd52ad1e19058357de934f1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2067351Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 7c34a225
......@@ -1479,8 +1479,6 @@ class Changelist(object):
change=change, parallel=options.parallel)
if not hook_results.should_continue():
return 1
if not options.reviewers and hook_results.reviewers:
options.reviewers = hook_results.reviewers.split(',')
self.ExtendCC(hook_results.more_cc)
print_stats(git_diff_args)
......
......@@ -296,7 +296,6 @@ class PresubmitOutput(object):
def __init__(self, input_stream=None, output_stream=None):
self.input_stream = input_stream
self.output_stream = output_stream
self.reviewers = []
self.more_cc = []
self.written_output = []
self.error_count = 0
......@@ -1672,23 +1671,6 @@ def DoPresubmitChecks(change,
else:
notifications.append(result)
if json_output:
# Write the presubmit results to json output
presubmit_results = {
'errors': [
error.json_format() for error in errors
],
'notifications': [
notification.json_format() for notification in notifications
],
'warnings': [
warning.json_format() for warning in warnings
]
}
gclient_utils.FileWrite(
json_output, json.dumps(presubmit_results, sort_keys=True))
output.write('\n')
for name, items in (('Messages', notifications),
('Warnings', warnings),
......@@ -1712,6 +1694,25 @@ def DoPresubmitChecks(change,
else:
output.write('Presubmit checks passed.\n')
if json_output:
# Write the presubmit results to json output
presubmit_results = {
'errors': [
error.json_format() for error in errors
],
'notifications': [
notification.json_format() for notification in notifications
],
'warnings': [
warning.json_format() for warning in warnings
],
'should_continue': output.should_continue(),
'more_cc': output.more_cc,
}
gclient_utils.FileWrite(
json_output, json.dumps(presubmit_results, sort_keys=True))
global _ASKED_FOR_FEEDBACK
# Ask for feedback one time out of 5.
if (len(results) and random.randint(0, 4) == 0 and not _ASKED_FOR_FEEDBACK):
......@@ -1875,7 +1876,7 @@ def main(argv=None):
'all PRESUBMIT files in parallel.')
parser.add_argument('--json_output',
help='Write presubmit errors to json output.')
parser.add_argument('--all-files', action='store_true',
parser.add_argument('--all_files', action='store_true',
help='Mark all files under source control as modified.')
parser.add_argument('files', nargs='*',
help='List of files to be marked as modified when '
......
......@@ -594,6 +594,7 @@ class PresubmitUnittest(PresubmitTestsBase):
fake_notify_long_text = 'Notification long text...'
always_fail_presubmit_script = """
def CheckChangeOnUpload(input_api, output_api):
output_api.more_cc = ['me@example.com']
return [
output_api.PresubmitError("%s",%s, "%s"),
output_api.PresubmitError("%s",%s, "%s"),
......@@ -646,7 +647,9 @@ def CheckChangeOnCommit(input_api, output_api):
'fatal': False,
'long_text': fake_warning_long_text
}
]
],
'should_continue': False,
'more_cc': ['me@example.com'],
}
fake_result_json = json.dumps(fake_result, sort_keys=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment