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

Side by Side Diff: chrome/browser/resources/PRESUBMIT.py

Issue 2729403003: [presubmit] check for long lines in HTML files (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Presubmit script for files in chrome/browser/resources. 5 """Presubmit script for files in chrome/browser/resources.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name) 85 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name)
86 type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|' 86 type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|'
87 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")') 87 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")')
88 88
89 match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL) 89 match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL)
90 return (match and 90 return (match and
91 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) 91 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3)))
92 92
93 93
94 def CheckHtml(input_api, output_api):
95 return input_api.canned_checks.CheckLongLines(input_api, output_api, 80)
tommycli 2017/03/06 22:06:15 Read 2nd comment first... seems a bit redundant t
96
97
94 def RunVulcanizeTests(input_api, output_api): 98 def RunVulcanizeTests(input_api, output_api):
95 presubmit_path = input_api.PresubmitLocalPath() 99 presubmit_path = input_api.PresubmitLocalPath()
96 tests = [input_api.os_path.join(presubmit_path, 'vulcanize_gn_test.py')] 100 tests = [input_api.os_path.join(presubmit_path, 'vulcanize_gn_test.py')]
97 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) 101 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests)
98 102
99 103
100 def _CheckChangeOnUploadOrCommit(input_api, output_api): 104 def _CheckChangeOnUploadOrCommit(input_api, output_api):
101 results = CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) 105 results = CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH)
102 affected = input_api.AffectedFiles() 106 affected = input_api.AffectedFiles()
107 if any(f for f in affected if f.LocalPath().endswith('.html')):
108 results += CheckHtml(input_api, output_api)
tommycli 2017/03/06 22:06:15 I wonder why this isn't included already via: http
dschuyler 2017/03/07 01:14:56 Afaik, the canned checks provide functionality, bu
103 if any(f for f in affected if f.LocalPath().endswith('vulcanize_gn.py')): 109 if any(f for f in affected if f.LocalPath().endswith('vulcanize_gn.py')):
104 results += RunVulcanizeTests(input_api, output_api) 110 results += RunVulcanizeTests(input_api, output_api)
105 return results 111 return results
106 112
107 113
108 def CheckChangeOnUpload(input_api, output_api): 114 def CheckChangeOnUpload(input_api, output_api):
109 return _CheckChangeOnUploadOrCommit(input_api, output_api) 115 return _CheckChangeOnUploadOrCommit(input_api, output_api)
110 116
111 117
112 def CheckChangeOnCommit(input_api, output_api): 118 def CheckChangeOnCommit(input_api, output_api):
113 return _CheckChangeOnUploadOrCommit(input_api, output_api) 119 return _CheckChangeOnUploadOrCommit(input_api, output_api)
114 120
115 121
116 def PostUploadHook(cl, change, output_api): 122 def PostUploadHook(cl, change, output_api):
117 return output_api.EnsureCQIncludeTrybotsAreAdded( 123 return output_api.EnsureCQIncludeTrybotsAreAdded(
118 cl, 124 cl,
119 [ 125 [
120 'master.tryserver.chromium.linux:closure_compilation', 126 'master.tryserver.chromium.linux:closure_compilation',
121 ], 127 ],
122 'Automatically added optional Closure bots to run on CQ.') 128 'Automatically added optional Closure bots to run on CQ.')
OLDNEW
« 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