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

Unified Diff: PRESUBMIT.py

Issue 2792103002: Reland of Adding PRESUBMIT check on google::protobuf (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 72e4326fe4f2e9a3784156695aed3063dcc6a49f..91b108c528721deba4f7f0e62c8a9249cf68d183 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -473,6 +473,26 @@
return input_api.RunTests(tests, parallel=True)
+def _CheckUsageOfGoogleProtobufNamespace(input_api, output_api):
+ """Checks that the namespace google::protobuf has not been used."""
+ files = []
+ pattern = input_api.re.compile(r'google::protobuf')
+ proto_utils_path = os.path.join('webrtc', 'base', 'protobuf_utils.h')
+ for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
+ if f.LocalPath() in [proto_utils_path, 'PRESUBMIT.py']:
+ continue
+ contents = input_api.ReadFile(f)
+ if pattern.search(contents):
+ files.append(f)
+
+ if files:
+ return [output_api.PresubmitError(
+ 'Please avoid to use namespace `google::protobuf` directly.\n'
+ 'Add a using directive in `%s` and include that header instead.'
+ % proto_utils_path, files)]
+ return []
+
+
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
@@ -541,6 +561,7 @@
results.extend(_CheckUnwantedDependencies(input_api, output_api))
results.extend(_CheckJSONParseErrors(input_api, output_api))
results.extend(_RunPythonTests(input_api, output_api))
+ results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api))
return results
« 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