Skip to content

Commit

Permalink
Add presubmit checks to verify that README.chromium files have been u…
Browse files Browse the repository at this point in the history
…pdated 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
  • Loading branch information
cdn@chromium.org committed Mar 31, 2011
1 parent adefec5 commit b4373e6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
72 changes: 72 additions & 0 deletions third_party/PRESUBMIT.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions third_party/README.chromium.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Name: Descriptive name of the package
Short Name: Name the package is distributed under (ex. libxml, openssl, etc)
URL: The URL where the package lives
Version: A searchable version number for the package (if the package does not version or is versioned by date or revision this field should be "unknown" and the revision should be listed in the appropriate field)
Revision: The current revision of the package (or change id)
License File: File that contains a copy of the package's license
Included In Release: Either yes or no depending on whether this package is shipped in releases. For example openssl is shipped where cygwin is not.
Version: A searchable version number for the package (if the package does not version or is versioned by date or revision this field should be "0" and the revision, or date should be enumerated in the appropriate field)
Date: (OPTIONAL if version is supplied) The date that the package was updated
Revision: (OPTIONAL if version is supplied) The current revision of the package
License: The license under which the package is distributed
License File: (OPTIONAL) File that contains a copy of the packages license
Security Critical: Either yes or no depending on whether this package is shipped in releases. For example openssl is critical where cygwin is not.

Description:
A short description of what the package is and is used for.
Expand Down

0 comments on commit b4373e6

Please sign in to comment.