| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 32 for more details about the presubmit API built into gcl. | 32 for more details about the presubmit API built into gcl. |
| 33 """ | 33 """ |
| 34 | 34 |
| 35 import sys | 35 import sys |
| 36 | 36 |
| 37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio
r to committing!" | 37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio
r to committing!" |
| 38 | 38 |
| 39 | 39 |
| 40 def _CheckNodeAndNPMModules(input_api, output_api): |
| 41 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s
cripts", "node.py") |
| 42 process = input_api.subprocess.Popen( |
| 43 [input_api.python_executable, node_script_path], |
| 44 stdout=input_api.subprocess.PIPE, |
| 45 stderr=input_api.subprocess.STDOUT) |
| 46 out, _ = process.communicate() |
| 47 if process.returncode != 0: |
| 48 return [output_api.PresubmitError(out)] |
| 49 return [output_api.PresubmitNotifyResult(out)] |
| 50 |
| 51 |
| 40 def _CheckDevtoolsStyle(input_api, output_api): | 52 def _CheckDevtoolsStyle(input_api, output_api): |
| 41 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f
.Action() != "D"] | 53 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f
.Action() != "D"] |
| 42 | 54 |
| 43 devtools_root = input_api.PresubmitLocalPath() | 55 devtools_root = input_api.PresubmitLocalPath() |
| 44 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") | 56 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") |
| 45 affected_front_end_files = [file_name for file_name in local_paths if devtoo
ls_front_end in file_name and file_name.endswith(".js")] | 57 affected_front_end_files = [file_name for file_name in local_paths if devtoo
ls_front_end in file_name and file_name.endswith(".js")] |
| 46 affected_front_end_files = [input_api.os_path.relpath(file_name, devtools_ro
ot) for file_name in affected_front_end_files] | 58 affected_front_end_files = [input_api.os_path.relpath(file_name, devtools_ro
ot) for file_name in affected_front_end_files] |
| 47 if len(affected_front_end_files) > 0: | 59 if len(affected_front_end_files) > 0: |
| 48 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 60 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 49 "scripts", "lint_javascript.py") | 61 "scripts", "lint_javascript.py") |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 for line_number, line in f.ChangedContents(): | 158 for line_number, line in f.ChangedContents(): |
| 147 if "/deep/" in line: | 159 if "/deep/" in line: |
| 148 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel
ector") % (f.LocalPath(), line_number))) | 160 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel
ector") % (f.LocalPath(), line_number))) |
| 149 if "::shadow" in line: | 161 if "::shadow" in line: |
| 150 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s
elector") % (f.LocalPath(), line_number))) | 162 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s
elector") % (f.LocalPath(), line_number))) |
| 151 return results | 163 return results |
| 152 | 164 |
| 153 | 165 |
| 154 def CheckChangeOnUpload(input_api, output_api): | 166 def CheckChangeOnUpload(input_api, output_api): |
| 155 results = [] | 167 results = [] |
| 168 results.extend(_CheckNodeAndNPMModules(input_api, output_api)) |
| 156 results.extend(_CheckDevtoolsStyle(input_api, output_api)) | 169 results.extend(_CheckDevtoolsStyle(input_api, output_api)) |
| 157 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) | 170 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) |
| 158 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) | 171 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) |
| 159 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) | 172 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) |
| 160 results.extend(_CheckCSSViolations(input_api, output_api)) | 173 results.extend(_CheckCSSViolations(input_api, output_api)) |
| 161 return results | 174 return results |
| 162 | 175 |
| 163 | 176 |
| 164 def CheckChangeOnCommit(input_api, output_api): | 177 def CheckChangeOnCommit(input_api, output_api): |
| 165 return [] | 178 return [] |
| OLD | NEW |