| OLD | NEW |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | 1 # Copyright (C) 2014 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 def _CheckNodeAndNPMModules(input_api, output_api): | 37 def _CheckNodeAndNPMModules(input_api, output_api): |
| 38 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s
cripts", "install_node_deps.py") | 38 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s
cripts", "install_node_deps.py") |
| 39 process = input_api.subprocess.Popen( | 39 process = input_api.subprocess.Popen( |
| 40 [input_api.python_executable, node_script_path], stdout=input_api.subpro
cess.PIPE, stderr=input_api.subprocess.STDOUT) | 40 [input_api.python_executable, node_script_path], stdout=input_api.subpro
cess.PIPE, stderr=input_api.subprocess.STDOUT) |
| 41 out, _ = process.communicate() | 41 out, _ = process.communicate() |
| 42 if process.returncode != 0: | 42 if process.returncode != 0: |
| 43 return [output_api.PresubmitError(out)] | 43 return [output_api.PresubmitError(out)] |
| 44 return [output_api.PresubmitNotifyResult(out)] | 44 return [output_api.PresubmitNotifyResult(out)] |
| 45 | 45 |
| 46 | 46 |
| 47 def _CheckBuildGN(input_api, output_api): |
| 48 original_sys_path = sys.path |
| 49 try: |
| 50 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPa
th(), "scripts")] |
| 51 import install_node_deps |
| 52 finally: |
| 53 sys.path = original_sys_path |
| 54 |
| 55 node_path, _ = install_node_deps.resolve_node_paths() |
| 56 |
| 57 script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "script
s", "check_gn.js") |
| 58 process = input_api.subprocess.Popen( |
| 59 [node_path, script_path], stdout=input_api.subprocess.PIPE, stderr=input
_api.subprocess.STDOUT) |
| 60 out, _ = process.communicate() |
| 61 |
| 62 if process.returncode != 0: |
| 63 return [output_api.PresubmitError(out)] |
| 64 return [output_api.PresubmitNotifyResult(out)] |
| 65 |
| 66 |
| 47 def _CheckFormat(input_api, output_api): | 67 def _CheckFormat(input_api, output_api): |
| 48 | 68 |
| 49 def popen(args): | 69 def popen(args): |
| 50 return input_api.subprocess.Popen(args=args, stdout=input_api.subprocess
.PIPE, stderr=input_api.subprocess.STDOUT) | 70 return input_api.subprocess.Popen(args=args, stdout=input_api.subprocess
.PIPE, stderr=input_api.subprocess.STDOUT) |
| 51 | 71 |
| 52 affected_files = _getAffectedJSFiles(input_api) | 72 affected_files = _getAffectedJSFiles(input_api) |
| 53 if len(affected_files) == 0: | 73 if len(affected_files) == 0: |
| 54 return [] | 74 return [] |
| 55 original_sys_path = sys.path | 75 original_sys_path = sys.path |
| 56 try: | 76 try: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if "/deep/" in line: | 198 if "/deep/" in line: |
| 179 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel
ector") % (f.LocalPath(), line_number))) | 199 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel
ector") % (f.LocalPath(), line_number))) |
| 180 if "::shadow" in line: | 200 if "::shadow" in line: |
| 181 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s
elector") % (f.LocalPath(), line_number))) | 201 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s
elector") % (f.LocalPath(), line_number))) |
| 182 return results | 202 return results |
| 183 | 203 |
| 184 | 204 |
| 185 def CheckChangeOnUpload(input_api, output_api): | 205 def CheckChangeOnUpload(input_api, output_api): |
| 186 results = [] | 206 results = [] |
| 187 results.extend(_CheckNodeAndNPMModules(input_api, output_api)) | 207 results.extend(_CheckNodeAndNPMModules(input_api, output_api)) |
| 208 results.extend(_CheckBuildGN(input_api, output_api)) |
| 188 results.extend(_CheckFormat(input_api, output_api)) | 209 results.extend(_CheckFormat(input_api, output_api)) |
| 189 results.extend(_CheckDevtoolsStyle(input_api, output_api)) | 210 results.extend(_CheckDevtoolsStyle(input_api, output_api)) |
| 190 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) | 211 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) |
| 191 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) | 212 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) |
| 192 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) | 213 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) |
| 193 results.extend(_CheckCSSViolations(input_api, output_api)) | 214 results.extend(_CheckCSSViolations(input_api, output_api)) |
| 194 return results | 215 return results |
| 195 | 216 |
| 196 | 217 |
| 197 def CheckChangeOnCommit(input_api, output_api): | 218 def CheckChangeOnCommit(input_api, output_api): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 211 def _getAffectedJSFiles(input_api): | 232 def _getAffectedJSFiles(input_api): |
| 212 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f
.Action() != "D"] | 233 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f
.Action() != "D"] |
| 213 devtools_root = input_api.PresubmitLocalPath() | 234 devtools_root = input_api.PresubmitLocalPath() |
| 214 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") | 235 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") |
| 215 devtools_scripts = input_api.os_path.join(devtools_root, "scripts") | 236 devtools_scripts = input_api.os_path.join(devtools_root, "scripts") |
| 216 affected_js_files = [ | 237 affected_js_files = [ |
| 217 file_name for file_name in local_paths | 238 file_name for file_name in local_paths |
| 218 if (devtools_front_end in file_name or devtools_scripts in file_name) an
d file_name.endswith(".js") | 239 if (devtools_front_end in file_name or devtools_scripts in file_name) an
d file_name.endswith(".js") |
| 219 ] | 240 ] |
| 220 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in
affected_js_files] | 241 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in
affected_js_files] |
| OLD | NEW |