| 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 | 41 |
| 39 new_contents = xib.NewContents() | 42 new_contents = xib.NewContents() |
| 40 if not new_contents: | 43 if not new_contents: |
| 41 # Deleting files is always fine. | 44 # Deleting files is always fine. |
| 42 continue | 45 continue |
| 43 | 46 |
| 44 for line in new_contents: | 47 for line in new_contents: |
| 45 m = re.search(SYSTEM_VERSION_RE, line) | 48 m = re.search(SYSTEM_VERSION_RE, line) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 84 |
| 82 def CheckChangeOnUpload(input_api, output_api): | 85 def CheckChangeOnUpload(input_api, output_api): |
| 83 # Allow uploads to happen even if the presubmit fails, so that contributors | 86 # Allow uploads to happen even if the presubmit fails, so that contributors |
| 84 # can ask their reviewer or another person to re-save the XIBs for them. | 87 # can ask their reviewer or another person to re-save the XIBs for them. |
| 85 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 88 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
| 86 error_type=output_api.PresubmitPromptWarning) | 89 error_type=output_api.PresubmitPromptWarning) |
| 87 | 90 |
| 88 def CheckChangeOnCommit(input_api, output_api): | 91 def CheckChangeOnCommit(input_api, output_api): |
| 89 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 92 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
| 90 error_type=output_api.PresubmitError) | 93 error_type=output_api.PresubmitError) |
| OLD | NEW |