Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/PRESUBMIT.py |
| diff --git a/third_party/WebKit/Source/core/inspector/PRESUBMIT.py b/third_party/WebKit/Source/core/inspector/PRESUBMIT.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..696f26372a2220dd3bcd485b3005b1a81a7a5677 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/inspector/PRESUBMIT.py |
| @@ -0,0 +1,35 @@ |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +compile_note = "Be sure to run your patch with Source/devtools/scripts/compile_frontend.py script prior to committing!" |
|
dgozman
2017/02/17 01:20:18
Drop this.
chenwilliam
2017/02/17 02:17:31
Done.
|
| + |
| + |
| +def _CompileDevtoolsFrontend(input_api, output_api): |
| + # Need to get all affected files from change (not just within this subtree) |
| + local_paths = [f.LocalPath() for f in input_api.change.AffectedFiles()] |
| + devtools = input_api.os_path.join("third_party", "WebKit", "Source", "devtools") |
|
dgozman
2017/02/17 01:20:18
I wonder whether we should instead have a single p
chenwilliam
2017/02/17 02:17:31
I considered it and it would reduce code duplicati
|
| + |
| + # If a devtools file is changed, the PRESUBMIT hook in Source/devtools |
| + # will run closure compiler |
| + if (any("browser_protocol.json" in path for path in local_paths) and |
| + all(devtools not in path for path in local_paths)): |
| + compile_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "..", "..", "devtools", "scripts", "compile_frontend.py") |
| + out, _ = input_api.subprocess.Popen( |
| + [input_api.python_executable, compile_path], stdout=input_api.subprocess.PIPE, |
| + stderr=input_api.subprocess.STDOUT).communicate() |
| + if "ERROR" in out or "WARNING" in out: |
| + return [output_api.PresubmitError(out)] |
| + if "NOTE" in out: |
| + return [output_api.PresubmitPromptWarning(out + compile_note)] |
| + return [] |
| + |
| + |
| +def CheckChangeOnUpload(input_api, output_api): |
| + results = [] |
| + results.extend(_CompileDevtoolsFrontend(input_api, output_api)) |
| + return results |
| + |
| + |
| +def CheckChangeOnCommit(input_api, output_api): |
| + return [] |