Chromium Code Reviews| 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 rietveld_obj = cl.RpcServer() |
| 10 description = rietveld_obj.get_description(cl.issue) | 10 description = rietveld_obj.get_description(cl.issue) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 if new_description == description: | 24 if new_description == description: |
| 25 return [] | 25 return [] |
| 26 | 26 |
| 27 rietveld_obj.update_description(cl.issue, new_description) | 27 rietveld_obj.update_description(cl.issue, new_description) |
| 28 return [output_api.PresubmitNotifyResult( | 28 return [output_api.PresubmitNotifyResult( |
| 29 'Automatically added optional Closure bots to run on CQ.')] | 29 'Automatically added optional Closure bots to run on CQ.')] |
| 30 | 30 |
| 31 | 31 |
| 32 def CheckChangeOnUpload(input_api, output_api): | 32 def CheckChangeOnUpload(input_api, output_api): |
| 33 return _CheckForTranslations(input_api, output_api) | 33 return _CommonChecks(input_api, output_api) |
| 34 | 34 |
| 35 | 35 |
| 36 def CheckChangeOnCommit(input_api, output_api): | 36 def CheckChangeOnCommit(input_api, output_api): |
| 37 return _CheckForTranslations(input_api, output_api) | 37 return _CommonChecks(input_api, output_api) |
| 38 | 38 |
| 39 | 39 |
| 40 def _CheckForTranslations(input_api, output_api): | 40 def _CheckForTranslations(input_api, output_api): |
| 41 shared_keywords = ['i18n('] | 41 shared_keywords = ['i18n('] |
| 42 html_keywords = shared_keywords + ['$118n{'] | 42 html_keywords = shared_keywords + ['$118n{'] |
| 43 js_keywords = shared_keywords + ['I18nBehavior', 'loadTimeData.'] | 43 js_keywords = shared_keywords + ['I18nBehavior', 'loadTimeData.'] |
| 44 | 44 |
| 45 errors = [] | 45 errors = [] |
| 46 | 46 |
| 47 for f in input_api.AffectedFiles(): | 47 for f in input_api.AffectedFiles(): |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 61 errors.append("%s:%d\n%s" % (f.LocalPath(), lnum, line)) | 61 errors.append("%s:%d\n%s" % (f.LocalPath(), lnum, line)) |
| 62 | 62 |
| 63 if not errors: | 63 if not errors: |
| 64 return [] | 64 return [] |
| 65 | 65 |
| 66 return [output_api.PresubmitError("\n".join(errors) + """ | 66 return [output_api.PresubmitError("\n".join(errors) + """ |
| 67 | 67 |
| 68 Don't embed translations directly in shared UI code. Instead, inject your | 68 Don't embed translations directly in shared UI code. Instead, inject your |
| 69 translation from the place using the shared code. For an example: see | 69 translation from the place using the shared code. For an example: see |
| 70 <cr-dialog>#closeText (http://bit.ly/2eLEsqh).""")] | 70 <cr-dialog>#closeText (http://bit.ly/2eLEsqh).""")] |
| 71 | |
| 72 | |
| 73 def _CommonChecks(input_api, output_api): | |
| 74 results = [] | |
| 75 results += _CheckForTranslations(input_api, output_api) | |
| 76 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) | |
|
dpapad
2016/12/22 00:59:13
Can you ensure that this does not create a problem
Dan Beam
2016/12/22 00:59:54
right, there are no crisper files in ui/webui/reso
| |
| 77 return results | |
| OLD | NEW |