forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add presubmit checks to verify that README.chromium files have been u…
…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
Showing
2 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters