summaryrefslogtreecommitdiffstats
path: root/chromium/components/search_engines/PRESUBMIT.py
blob: 2e4cfae55d02e9abb17e39b4ce804730501dfd4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Presubmit script for changes affecting components/search_engines/

See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""

import os

def _CheckPrepopulatedEnginesVersion(input_api, output_api):
  """Check that no changes were made to prepopulated_engines.json without
  also updating kCurrentDataVersion"""
  results = []
  file = next((f for f in input_api.AffectedFiles()
                 if os.path.basename(f.LocalPath()) ==
                 "prepopulated_engines.json"), None)

  if file != None and not any(line for line in file.ChangedContents()
                              if "kCurrentDataVersion" in line[1]):
      results.append(output_api.PresubmitPromptWarning(
          ("prepopulated_engines.json changed but kCurrentDataVersion "
           "did not. Please ensure the version is rolled up when making "
           "meaningful changes to prepopulated_engines.json")))

  return results

def CheckChangeOnUpload(input_api, output_api):
  results = []
  results.extend(_CheckPrepopulatedEnginesVersion(input_api, output_api))
  return results