blob: b50dc3d5be987a5ea90ebcd21a059f5e4707c4c9 [file] [log] [blame]
# 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.
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 any of the following files is changed:
- components/subresource_filter/core/common/
- components/subresource_filter/core/common/flat/indexed_ruleset.fbs
and kIndexedFormatVersion constant stays intact, 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()
basename = input_api.basename(path)
if basename == '' or basename == 'indexed_ruleset.fbs':
indexed_ruleset_changed = True
if basename == '':
for (_, line) in affected_file.ChangedContents():
if 'const int RulesetIndexer::kIndexedFormatVersion =' in line:
indexed_ruleset_version_changed = True
# If the indexed ruleset version changed, ensure the perf benchmarks are using
# the new format.
out = []
if indexed_ruleset_changed and not indexed_ruleset_version_changed:
'Please make sure that IndexedRuleset modifications in '
'indexed_ruleset.fbs and do not require updating '
return out
def CheckChangeOnUpload(input_api, output_api):
return CheckIndexedRulesetVersion(input_api, output_api)