OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Presubmit script to verify that XIB changes are done with the right version. | 5 """Presubmit script to verify that XIB changes are done with the right version. |
6 | 6 |
7 See http://dev.chromium.org/developers/design-documents/mac-xib-files for more | 7 See http://dev.chromium.org/developers/design-documents/mac-xib-files for more |
8 information. | 8 information. |
9 """ | 9 """ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 r'<string key="IBDocument\.InterfaceBuilderVersion">([0-9]+)</string>' | 26 r'<string key="IBDocument\.InterfaceBuilderVersion">([0-9]+)</string>' |
27 | 27 |
28 def _CheckXIBSystemAndXcodeVersions(input_api, output_api, error_type): | 28 def _CheckXIBSystemAndXcodeVersions(input_api, output_api, error_type): |
29 affected_xibs = [x for x in input_api.AffectedFiles() | 29 affected_xibs = [x for x in input_api.AffectedFiles() |
30 if x.LocalPath().endswith('.xib')] | 30 if x.LocalPath().endswith('.xib')] |
31 | 31 |
32 incorrect_system_versions = [] | 32 incorrect_system_versions = [] |
33 incorrect_ib_versions = [] | 33 incorrect_ib_versions = [] |
34 | 34 |
35 for xib in affected_xibs: | 35 for xib in affected_xibs: |
| 36 if len(xib.NewContents()) == 0: |
| 37 continue |
| 38 |
36 system_version = None | 39 system_version = None |
37 ib_version = None | 40 ib_version = None |
38 for line in xib.NewContents(): | 41 for line in xib.NewContents(): |
39 m = re.search(SYSTEM_VERSION_RE, line) | 42 m = re.search(SYSTEM_VERSION_RE, line) |
40 if m: | 43 if m: |
41 system_version = (m.group(1), m.group(2), m.group(3)) | 44 system_version = (m.group(1), m.group(2), m.group(3)) |
42 | 45 |
43 m = re.search(IB_VERSION_RE, line) | 46 m = re.search(IB_VERSION_RE, line) |
44 if m: | 47 if m: |
45 ib_version = m.group(1) | 48 ib_version = m.group(1) |
(...skipping 29 matching lines...) Expand all Loading... |
75 | 78 |
76 def CheckChangeOnUpload(input_api, output_api): | 79 def CheckChangeOnUpload(input_api, output_api): |
77 # Allow uploads to happen even if the presubmit fails, so that contributors | 80 # Allow uploads to happen even if the presubmit fails, so that contributors |
78 # can ask their reviewer or another person to re-save the XIBs for them. | 81 # can ask their reviewer or another person to re-save the XIBs for them. |
79 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 82 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
80 error_type=output_api.PresubmitPromptWarning) | 83 error_type=output_api.PresubmitPromptWarning) |
81 | 84 |
82 def CheckChangeOnCommit(input_api, output_api): | 85 def CheckChangeOnCommit(input_api, output_api): |
83 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 86 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
84 error_type=output_api.PresubmitError) | 87 error_type=output_api.PresubmitError) |
OLD | NEW |