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

Unified Diff: components/subresource_filter/core/common/PRESUBMIT.py

Issue 2850813003: Add presubmit script checking FlatBuffer changes. (Closed)
Patch Set: Address comments. Created 3 years, 8 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 | components/subresource_filter/core/common/indexed_ruleset.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/subresource_filter/core/common/PRESUBMIT.py
diff --git a/components/subresource_filter/core/common/PRESUBMIT.py b/components/subresource_filter/core/common/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..bb1e72ce5202b2f4b8943245185b09805f703e8b
--- /dev/null
+++ b/components/subresource_filter/core/common/PRESUBMIT.py
@@ -0,0 +1,45 @@
+# 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.
+
+"""Presubmit script for subresource_filter component's core/common directory.
+
+See https://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into depot_tools.
+"""
+
+def CheckIndexedRulesetVersion(input_api, output_api):
+ """ Checks that IndexedRuleset format version is modified when necessary.
+
+ Whenever a *.fbs or indexed_ruleset.cc file is touched in
+ components/subresource_filter/core/common and kIndexedFormatVersion constant
+ is not changed, this check returns a presubmit warning to make sure the value
+ should not be updated.
+ """
+
+ indexed_ruleset_changed = False
+ indexed_ruleset_version_changed = False
+
+ for affected_file in input_api.AffectedFiles():
+ path = affected_file.LocalPath()
+ if not 'components/subresource_filter/core/common' in path:
+ continue
+ basename = input_api.basename(path)
+
+ if basename.endswith('.fbs') or basename == 'indexed_ruleset.cc':
+ indexed_ruleset_changed = True
+ if basename == 'indexed_ruleset.cc':
+ for (_, line) in affected_file.ChangedContents():
+ if 'kIndexedFormatVersion =' in line:
+ indexed_ruleset_version_changed = True
+ break
+
+ if indexed_ruleset_changed and not indexed_ruleset_version_changed:
+ return [output_api.PresubmitPromptWarning(
+ 'Please make sure that IndexedRuleset modifications in *.fbs and '
+ 'indexed_ruleset.cc do not require updating '
+ 'RulesetIndexer::kIndexedFormatVersion.')]
+ return []
+
+def CheckChangeOnUpload(input_api, output_api):
+ return CheckIndexedRulesetVersion(input_api, output_api)
« no previous file with comments | « no previous file | components/subresource_filter/core/common/indexed_ruleset.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698