OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 def _CheckThirdPartyReadmesUpdated(input_api, output_api): | 5 def _CheckThirdPartyReadmesUpdated(input_api, output_api): |
6 """ | 6 """ |
7 Checks to make sure that README.chromium files are properly updated | 7 Checks to make sure that README.chromium files are properly updated |
8 when dependancies in third_party are modified. | 8 when dependancies in third_party are modified. |
9 """ | 9 """ |
10 readmes = [] | 10 readmes = [] |
11 files = [] | 11 files = [] |
12 errors = [] | 12 errors = [] |
13 for f in input_api.AffectedFiles(): | 13 for f in input_api.AffectedFiles(): |
14 if f.LocalPath().startswith('third_party' + input_api.os_path.sep): | 14 if f.LocalPath().startswith('third_party' + input_api.os_path.sep): |
15 files.append(f) | 15 files.append(f) |
16 if f.LocalPath().endswith("README.chromium"): | 16 if f.LocalPath().endswith("README.chromium"): |
17 readmes.append(f) | 17 readmes.append(f) |
18 if files and not readmes: | 18 if files and not readmes: |
19 errors.append(output_api.PresubmitPromptWarning( | 19 errors.append(output_api.PresubmitPromptWarning( |
20 'When updating or adding third party code the appropriate\n' | 20 'When updating or adding third party code the appropriate\n' |
21 '\'README.chromium\' file should also be updated with the correct\n' | 21 '\'README.chromium\' file should also be updated with the correct\n' |
22 'version and package information.', files)) | 22 'version and package information.', files)) |
23 if not readmes: | 23 if not readmes: |
24 return errors | 24 return errors |
25 | 25 |
26 name_pattern = input_api.re.compile( | 26 name_pattern = input_api.re.compile( |
27 r'^Name: [a-zA-Z0-9_\-\.]+\r?$', | 27 r'^Name: [a-zA-Z0-9_\-\. ]+\r?$', |
28 input_api.re.IGNORECASE | input_api.re.MULTILINE) | 28 input_api.re.IGNORECASE | input_api.re.MULTILINE) |
29 shortname_pattern = input_api.re.compile( | 29 shortname_pattern = input_api.re.compile( |
30 r'^Short Name: [a-zA-Z0-9_\-\.]+\r?$', | 30 r'^Short Name: [a-zA-Z0-9_\-\.]+\r?$', |
31 input_api.re.IGNORECASE | input_api.re.MULTILINE) | 31 input_api.re.IGNORECASE | input_api.re.MULTILINE) |
32 version_pattern = input_api.re.compile( | 32 version_pattern = input_api.re.compile( |
33 r'^Version: [a-zA-Z0-9_\-\.]+\r?$', | 33 r'^Version: [a-zA-Z0-9_\-\.:]+\r?$', |
34 input_api.re.IGNORECASE | input_api.re.MULTILINE) | 34 input_api.re.IGNORECASE | input_api.re.MULTILINE) |
35 release_pattern = input_api.re.compile( | 35 release_pattern = input_api.re.compile( |
36 r'Security Critical: (yes)|(no)\r?$', | 36 r'Security Critical: (yes)|(no)\r?$', |
37 input_api.re.IGNORECASE | input_api.re.MULTILINE) | 37 input_api.re.IGNORECASE | input_api.re.MULTILINE) |
38 | 38 |
39 for f in readmes: | 39 for f in readmes: |
40 contents = input_api.ReadFile(f) | 40 contents = input_api.ReadFile(f) |
41 if (not shortname_pattern.search(contents) | 41 if (not shortname_pattern.search(contents) |
42 and not name_pattern.search(contents)): | 42 and not name_pattern.search(contents)): |
43 errors.append(output_api.PresubmitError( | 43 errors.append(output_api.PresubmitError( |
(...skipping 14 matching lines...) Expand all Loading... |
58 'field. This field specifies whether the package is built with\n' | 58 'field. This field specifies whether the package is built with\n' |
59 'Chromium. Check README.chromium.template for details.', | 59 'Chromium. Check README.chromium.template for details.', |
60 [f])) | 60 [f])) |
61 return errors | 61 return errors |
62 | 62 |
63 | 63 |
64 def CheckChangeOnUpload(input_api, output_api): | 64 def CheckChangeOnUpload(input_api, output_api): |
65 results = [] | 65 results = [] |
66 results.extend(_CheckThirdPartyReadmesUpdated(input_api, output_api)) | 66 results.extend(_CheckThirdPartyReadmesUpdated(input_api, output_api)) |
67 return results | 67 return results |
OLD | NEW |