Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Unified Diff: presubmit_support.py

Issue 112503005: Have presubmit.py accept an option to output trybot data as json. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Address maruel's nits. Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index fa8cb129e234fac6b1af0f1f7e1ed80828fd0d50..d22c9c07296278de38fd2d01a23d304986b0fe15 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -6,7 +6,7 @@
"""Enables directory-specific presubmit checks to run at upload and/or commit.
"""
-__version__ = '1.7.0'
+__version__ = '1.8.0'
# TODO(joi) Add caching where appropriate/needed. The API is designed to allow
# caching (between all different invocations of presubmit scripts for a given
@@ -1430,6 +1430,8 @@ def Main(argv):
parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP)
parser.add_option("--rietveld_fetch", action='store_true', default=False,
help=optparse.SUPPRESS_HELP)
+ parser.add_option("--trybot-json",
+ help="Output trybot information to the file specified.")
options, args = parser.parse_args(argv)
if options.verbose >= 2:
logging.basicConfig(level=logging.DEBUG)
@@ -1454,6 +1456,31 @@ def Main(argv):
options.description = props['description']
logging.info('Got author: "%s"', options.author)
logging.info('Got description: """\n%s\n"""', options.description)
+ if options.trybot_json:
+ with open(options.trybot_json, 'w') as f:
+ # Python's sets aren't JSON-encodable, so we convert them to lists here.
+ class SetEncoder(json.JSONEncoder):
+ # pylint: disable=E0202
+ def default(self, obj):
+ if isinstance(obj, set):
+ return sorted(obj)
+ return json.JSONEncoder.default(self, obj)
+ change = change_class(options.name,
+ options.description,
+ options.root,
+ files,
+ options.issue,
+ options.patchset,
+ options.author)
+ trybots = DoGetTrySlaves(
+ change,
+ change.LocalPaths(),
+ change.RepositoryRoot(),
+ None,
+ None,
+ options.verbose,
+ sys.stdout)
+ json.dump(trybots, f, cls=SetEncoder)
try:
with canned_check_filter(options.skip_canned):
results = DoPresubmitChecks(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698