| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 | 7 |
| 8 def PostUploadHook(cl, change, output_api): | 8 def PostUploadHook(cl, change, output_api): |
| 9 rietveld_obj = cl.RpcServer() | 9 return output_api.EnsureCQIncludeTrybotsAreAdded( |
| 10 description = rietveld_obj.get_description(cl.issue) | 10 cl, |
| 11 | 11 [ |
| 12 existing_bots = (change.CQ_INCLUDE_TRYBOTS or '').split(';') | 12 'master.tryserver.chromium.linux:closure_compilation', |
| 13 clean_bots = set(filter(None, map(lambda s: s.strip(), existing_bots))) | 13 ], |
| 14 new_bots = clean_bots | set( | 14 'Automatically added optional Closure bots to run on CQ.') |
| 15 ['master.tryserver.chromium.linux:closure_compilation']) | |
| 16 new_tag = 'CQ_INCLUDE_TRYBOTS=%s' % ';'.join(new_bots) | |
| 17 | |
| 18 if clean_bots: | |
| 19 tag_reg = '^CQ_INCLUDE_TRYBOTS=.*$' | |
| 20 new_description = re.sub(tag_reg, new_tag, description, flags=re.M | re.I) | |
| 21 else: | |
| 22 new_description = description + '\n' + new_tag | |
| 23 | |
| 24 if new_description == description: | |
| 25 return [] | |
| 26 | |
| 27 rietveld_obj.update_description(cl.issue, new_description) | |
| 28 return [output_api.PresubmitNotifyResult( | |
| 29 'Automatically added optional Closure bots to run on CQ.')] | |
| 30 | 15 |
| 31 | 16 |
| 32 def CheckChangeOnUpload(input_api, output_api): | 17 def CheckChangeOnUpload(input_api, output_api): |
| 33 return _CommonChecks(input_api, output_api) | 18 return _CommonChecks(input_api, output_api) |
| 34 | 19 |
| 35 | 20 |
| 36 def CheckChangeOnCommit(input_api, output_api): | 21 def CheckChangeOnCommit(input_api, output_api): |
| 37 return _CommonChecks(input_api, output_api) | 22 return _CommonChecks(input_api, output_api) |
| 38 | 23 |
| 39 | 24 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 translation from the place using the shared code. For an example: see | 56 translation from the place using the shared code. For an example: see |
| 72 <cr-dialog>#closeText (http://bit.ly/2eLEsqh).""")] | 57 <cr-dialog>#closeText (http://bit.ly/2eLEsqh).""")] |
| 73 | 58 |
| 74 | 59 |
| 75 def _CommonChecks(input_api, output_api): | 60 def _CommonChecks(input_api, output_api): |
| 76 results = [] | 61 results = [] |
| 77 results += _CheckForTranslations(input_api, output_api) | 62 results += _CheckForTranslations(input_api, output_api) |
| 78 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api, | 63 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api, |
| 79 check_js=True) | 64 check_js=True) |
| 80 return results | 65 return results |
| OLD | NEW |