summaryrefslogtreecommitdiffstats
path: root/third_party/PRESUBMIT.py
diff options
context:
space:
mode:
authorcdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 19:55:06 +0000
committercdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 19:55:06 +0000
commitb4373e6e6e73704a5296e87942ae93a635435588 (patch)
tree81d7bd3c5ef6034d9d4ea4e9a796373a5c52125c /third_party/PRESUBMIT.py
parentadefec58ada3ab8ffd373bb6cfc1e1b6adbad4eb (diff)
downloadchromium_src-b4373e6e6e73704a5296e87942ae93a635435588.zip
chromium_src-b4373e6e6e73704a5296e87942ae93a635435588.tar.gz
chromium_src-b4373e6e6e73704a5296e87942ae93a635435588.tar.bz2
Add presubmit checks to verify that README.chromium files have been updated and contain the proper meta data when files within third_party are modified.
Also fixed _CheckNoInterfacesInBase() which was broken on win32 as the path seperator was hardcoded. BUG=None TEST=N/A Review URL: http://codereview.chromium.org/6713009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/PRESUBMIT.py')
-rw-r--r--third_party/PRESUBMIT.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/third_party/PRESUBMIT.py b/third_party/PRESUBMIT.py
new file mode 100644
index 0000000..8ccb3d0
--- /dev/null
+++ b/third_party/PRESUBMIT.py
@@ -0,0 +1,72 @@
+# Copyright (c) 2011 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.
+
+def _CheckThirdPartyReadmesUpdated(input_api, output_api):
+ """
+ Checks to make sure that README.chromium files are properly updated
+ when dependancies in third_party are modified.
+ """
+ readmes = []
+ files = []
+ errors = []
+ for f in input_api.AffectedFiles():
+ if f.LocalPath().startswith('third_party' + input_api.os_path.sep):
+ files.append(f)
+ if f.LocalPath().endswith("README.chromium"):
+ readmes.append(f)
+ if files and not readmes:
+ errors.append(output_api.PresubmitPromptWarning(
+ 'When updating or adding third party code the appropriate\n'
+ '\'README.chromium\' file should also be updated with the correct\n'
+ 'version and package information.', files))
+ if not readmes:
+ return errors
+
+ name_pattern = input_api.re.compile(
+ r'^Name: [a-zA-Z0-9_\-\.]+$',
+ input_api.re.IGNORECASE | input_api.re.MULTILINE)
+ shortname_pattern = input_api.re.compile(
+ r'^Short Name: [a-zA-Z0-9_\-\.]+$',
+ input_api.re.IGNORECASE | input_api.re.MULTILINE)
+ version_pattern = input_api.re.compile(
+ r'^Version: [a-zA-Z0-9_\-\.]+$',
+ input_api.re.IGNORECASE | input_api.re.MULTILINE)
+ release_pattern = input_api.re.compile(
+ r'Included In Release: (yes)|(no)$',
+ input_api.re.IGNORECASE | input_api.re.MULTILINE)
+
+ for file in readmes:
+ contents = input_api.ReadFile(f)
+ if not "Name: " in contents:
+ errors.append(output_api.PresubmitError(
+ 'Third party README files should contain a \'Name\' field.\n'
+ 'Check README.chromium.template for details.',
+ [file]))
+ if (not shortname_pattern.search(contents)
+ and not name_pattern.search(contents)):
+ errors.append(output_api.PresubmitError(
+ 'Third party README files should contain either a \'Short Name\' or\n'
+ 'a \'Name\' which is the name under which the package is\n'
+ 'distributed. Check README.chromium.template for details.',
+ [file]))
+ if not version_pattern.search(contents):
+ errors.append(output_api.PresubmitError(
+ 'Third party README files should contain a \'Version\' field.\n'
+ 'If the package is not versioned or the version is not known\n'
+ 'list the version as \'unknown\'.\n'
+ 'Check README.chromium.template for details.',
+ [file]))
+ if not release_pattern.search(contents):
+ errors.append(output_api.PresubmitError(
+ 'Third party README files should contain a \'Included In Release\'\n'
+ 'field. This field specifies whether the package is built with\n'
+ 'Chromium. Check README.chromium.template for details.',
+ [file]))
+ return errors
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ results = []
+ results.extend(_CheckThirdPartyReadmesUpdated(input_api, output_api))
+ return results \ No newline at end of file