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 |
11 import re | 11 import re |
12 | 12 |
13 # Minimum is Mac OS X 10.8.1 (12B19). | 13 # Minimum is Mac OS X 10.9.5 (13F34). |
14 HUMAN_DARWIN_VERSION = '10.8.x, x >= 1' | 14 HUMAN_DARWIN_VERSION = '10.9.x, x >= 1' |
15 ALLOWED_DARWIN_VERSION = 12 # Darwin 12 = 10.8. | 15 ALLOWED_DARWIN_VERSION = 13 # Darwin 12 = 10.9. |
16 MINIMUM_DARWIN_RELEASE = 'B' # Release B = 10.8.1. | 16 MINIMUM_DARWIN_RELEASE = 'F' # Release F = 10.9.5. |
17 | 17 |
18 MINIMUM_IB_VERSION = 2549 # Xcode 4.4.1. | 18 MINIMUM_IB_VERSION = 5053 # Xcode 5.1. |
19 MAXIMUM_IB_VERSION = 3084 # Xcode 4.6.x. | 19 MAXIMUM_IB_VERSION = 5056 # Xcode 5.1.1. |
20 HUMAN_IB_VERSION = '>= 4.4.1, <= 4.6.x' | 20 HUMAN_IB_VERSION = '>= 5.1, <= 5.1.1' |
21 | 21 |
22 SYSTEM_VERSION_RE = r'<string key="IBDocument\.SystemVersion">' + \ | 22 SYSTEM_VERSION_RE = r'<document .* systemVersion="([0-9]{,2})([A-Z])([0-9]+)"' |
23 '([0-9]{,2})([A-Z])([0-9]+)</string>' | |
24 | 23 |
25 IB_VERSION_RE = \ | 24 IB_VERSION_RE = \ |
26 r'<string key="IBDocument\.InterfaceBuilderVersion">([0-9]+)</string>' | 25 r'<plugIn identifier="com\.apple\.InterfaceBuilder\.CocoaPlugin" ' + \ |
| 26 'version="([0-9]+)"/>' |
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: | 36 if len(xib.NewContents()) == 0: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 def CheckChangeOnUpload(input_api, output_api): | 85 def CheckChangeOnUpload(input_api, output_api): |
86 # 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 |
87 # 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. |
88 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 88 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
89 error_type=output_api.PresubmitPromptWarning) | 89 error_type=output_api.PresubmitPromptWarning) |
90 | 90 |
91 def CheckChangeOnCommit(input_api, output_api): | 91 def CheckChangeOnCommit(input_api, output_api): |
92 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, | 92 return _CheckXIBSystemAndXcodeVersions(input_api, output_api, |
93 error_type=output_api.PresubmitError) | 93 error_type=output_api.PresubmitError) |
OLD | NEW |