OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 def _get_bucket_map(changelist, options, option_parser): | 343 def _get_bucket_map(changelist, options, option_parser): |
344 """Returns a dict mapping bucket names to builders and tests, | 344 """Returns a dict mapping bucket names to builders and tests, |
345 for triggering try jobs. | 345 for triggering try jobs. |
346 """ | 346 """ |
347 # If no bots are listed, we try to get a set of builders and tests based | 347 # If no bots are listed, we try to get a set of builders and tests based |
348 # on GetPreferredTryMasters functions in PRESUBMIT.py files. | 348 # on GetPreferredTryMasters functions in PRESUBMIT.py files. |
349 if not options.bot: | 349 if not options.bot: |
350 change = changelist.GetChange( | 350 change = changelist.GetChange( |
351 changelist.GetCommonAncestorWithUpstream(), None) | 351 changelist.GetCommonAncestorWithUpstream(), None) |
352 | 352 # Get try masters from PRESUBMIT.py files. |
353 masters = presubmit_support.DoGetTryMasters( | 353 return presubmit_support.DoGetTryMasters( |
354 change=change, | 354 change=change, |
355 changed_files=change.LocalPaths(), | 355 changed_files=change.LocalPaths(), |
356 repository_root=settings.GetRoot(), | 356 repository_root=settings.GetRoot(), |
357 default_presubmit=None, | 357 default_presubmit=None, |
358 project=None, | 358 project=None, |
359 verbose=options.verbose, | 359 verbose=options.verbose, |
360 output_stream=sys.stdout) | 360 output_stream=sys.stdout) |
361 | 361 |
362 if masters: | |
363 return masters | |
364 | |
365 # Fall back to deprecated method: get try slaves from PRESUBMIT.py | |
366 # files. | |
367 # TODO(qyearsley): Remove this. | |
368 options.bot = presubmit_support.DoGetTrySlaves( | |
369 change=change, | |
370 changed_files=change.LocalPaths(), | |
371 repository_root=settings.GetRoot(), | |
372 default_presubmit=None, | |
373 project=None, | |
374 verbose=options.verbose, | |
375 output_stream=sys.stdout) | |
376 | |
377 if not options.bot: | |
378 return {} | |
379 | |
380 # If a bucket or master is passed, then we assume all bots are under | |
381 # that one master. | |
382 if options.bucket: | 362 if options.bucket: |
383 return {options.bucket: {b: [] for b in options.bot}} | 363 return {options.bucket: {b: [] for b in options.bot}} |
384 if options.master: | 364 if options.master: |
385 return {_prefix_master(options.master): {b: [] for b in options.bot}} | 365 return {_prefix_master(options.master): {b: [] for b in options.bot}} |
386 | 366 |
387 # If bots are listed but no master or bucket, then we need to find out | 367 # If bots are listed but no master or bucket, then we need to find out |
388 # the corresponding master for each bot. | 368 # the corresponding master for each bot. |
389 bucket_map, error_message = _get_bucket_map_for_builders(options.bot) | 369 bucket_map, error_message = _get_bucket_map_for_builders(options.bot) |
390 if error_message: | 370 if error_message: |
391 option_parser.error( | 371 option_parser.error( |
(...skipping 4984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5376 if __name__ == '__main__': | 5356 if __name__ == '__main__': |
5377 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5357 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5378 # unit testing. | 5358 # unit testing. |
5379 fix_encoding.fix_encoding() | 5359 fix_encoding.fix_encoding() |
5380 setup_color.init() | 5360 setup_color.init() |
5381 try: | 5361 try: |
5382 sys.exit(main(sys.argv[1:])) | 5362 sys.exit(main(sys.argv[1:])) |
5383 except KeyboardInterrupt: | 5363 except KeyboardInterrupt: |
5384 sys.stderr.write('interrupted\n') | 5364 sys.stderr.write('interrupted\n') |
5385 sys.exit(1) | 5365 sys.exit(1) |
OLD | NEW |