1#!/usr/bin/python
2# Copyright (c) 2009 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import os.path
7
8# When files in these directories are changed, we display a warning.
9DEPENDENT_DIRS = set([
10  os.path.normpath("chrome/common/extensions/api"),
11  os.path.normpath("chrome/common/extensions/docs")
12])
13
14# Except for these directories.
15BLACKLIST_DIRS = set([
16  os.path.normpath("chrome/common/extensions/docs/server")
17])
18
19REBUILD_WARNING = """
20This change modifies file(s) which the extension docs depend on. You must
21rebuild the extension docs.
22
23Build by running the build.py script in chrome/common/extensions/docs/build/.
24
25Be sure to include any modified resulting static files
26(/common/extension/docs/*.html) in your final changelist.
27"""
28
29def CheckChange(input_api, output_api):
30  for f in input_api.AffectedFiles():
31    dir = os.path.normpath(input_api.os_path.dirname(f.LocalPath()))
32    while len(dir):
33      if dir in BLACKLIST_DIRS:
34        return []
35      if dir in DEPENDENT_DIRS:
36        return [output_api.PresubmitPromptWarning(REBUILD_WARNING)]
37      dir = os.path.dirname(dir)
38  return []
39
40def CheckChangeOnUpload(input_api, output_api):
41  return CheckChange(input_api, output_api)
42
43def CheckChangeOnCommit(input_api, output_api):
44  return CheckChange(input_api, output_api)
45