Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: chrome/app/nibs/PRESUBMIT.py

Issue 10950010: Re-save XIB files using Xcode 4.4.1 on Mac OS X 10.8.1. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: GTMUILocalizer Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/nibs/OneClickSigninBubble.xib ('k') | chrome/app/nibs/Panel.xib » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/nibs/PRESUBMIT.py
diff --git a/chrome/app/nibs/PRESUBMIT.py b/chrome/app/nibs/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..329763ca4703b30d143bcfcb81ee8ad52bebcd3f
--- /dev/null
+++ b/chrome/app/nibs/PRESUBMIT.py
@@ -0,0 +1,84 @@
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
Mark Mentovai 2012/09/18 20:16:59 What year, now?
Robert Sesek 2012/09/18 20:42:10 Oops.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Presubmit script to verify that XIB changes are done with the right version.
+
+See http://dev.chromium.org/developers/design-documents/mac-xib-files for more
+information.
+"""
+
+import re
+
+# Minimum is Mac OS X 10.8.1 (12B19).
+HUMAN_DARWIN_VERSION = '10.8.x'
Mark Mentovai 2012/09/18 20:16:59 Technically incorrect if you’re requiring 10.8.1 b
Robert Sesek 2012/09/18 20:42:10 Done.
+ALLOWED_DARWIN_VERSION = 12 # Darwin 12 = 10.8.
+MINIMUM_DARWIN_RELEASE = 'B' # Release B = 10.8.1.
+
+MINIMUM_IB_VERSION = 2549 # Xcode 4.4.1.
+MAXIMUM_IB_VERSION = 2800 # Xcode 4.5.x.
Mark Mentovai 2012/09/18 20:16:59 For the name of the variable to make sense, I thin
Robert Sesek 2012/09/18 20:42:10 The earliest 4.5 prerelease seed I found had build
+HUMAN_IB_VERSION = '4.4.x'
Mark Mentovai 2012/09/18 20:16:59 Similar to before, technically incorrect if you’re
Robert Sesek 2012/09/18 20:42:10 Done.
+
+SYSTEM_VERSION_RE = \
+ r'<string key="IBDocument\.SystemVersion">([0-9A-Z]+)</string>'
+
+IB_VERSION_RE = \
+ r'<string key="IBDocument\.InterfaceBuilderVersion">([0-9]+)</string>'
+
+def _CheckXIBSystemAndXcodeVersions(input_api, output_api, error_type):
+ affected_xibs = [x for x in input_api.AffectedFiles()
+ if x.LocalPath().endswith('.xib')]
+
+ incorrect_system_versions = []
+ incorrect_ib_versions = []
+
+ for xib in affected_xibs:
+ system_version = None
+ ib_version = None
+ for line in xib.NewContents():
Mark Mentovai 2012/09/18 20:16:59 Why don’t you have your REs anchored with ^ and $,
Robert Sesek 2012/09/18 20:42:10 The AffectedFile only provides iterators to the li
+ m = re.search(SYSTEM_VERSION_RE, line)
+ if m:
+ system_version = m.group(1)
+
+ m = re.search(IB_VERSION_RE, line)
+ if m:
+ ib_version = m.group(1)
+
+ if system_version is not None and ib_version is not None:
+ break
+
+ if system_version is None or len(system_version) < 3:
+ incorrect_system_versions.append(xib.LocalPath())
+ continue
+ if int(system_version[0:2]) != ALLOWED_DARWIN_VERSION:
Mark Mentovai 2012/09/18 20:16:59 Rather than system_version[0:2] and system_version
Robert Sesek 2012/09/18 20:42:10 Done.
+ incorrect_system_versions.append(xib.LocalPath())
+ continue
+ if system_version[2] < MINIMUM_DARWIN_RELEASE:
+ incorrect_system_versions.append(xib.LocalPath())
+ continue
+
+ if ib_version is None or int(ib_version) < MINIMUM_IB_VERSION or \
+ int(ib_version) >= MAXIMUM_IB_VERSION:
+ incorrect_ib_versions.append(xib.LocalPath())
+ continue
+
+ problems = []
+ if incorrect_system_versions:
+ problems.append(error_type(
+ 'XIB files need to be saved on Mac OS X ' + HUMAN_DARWIN_VERSION,
Mark Mentovai 2012/09/18 20:16:59 Can the message say which xib tripped the check? S
Robert Sesek 2012/09/18 20:42:10 That's what items= does.
+ items=incorrect_system_versions))
+ if incorrect_ib_versions:
+ problems.append(error_type(
+ 'XIB files need to be saved using Xcode ' + HUMAN_IB_VERSION,
+ items=incorrect_ib_versions))
+ return problems
+
+def CheckChangeOnUpload(input_api, output_api):
+ # Allow uploads to happen even if the presubmit fails, so that contributors
+ # can ask their reviewer or another person to re-save the XIBs for them.
+ return _CheckXIBSystemAndXcodeVersions(input_api, output_api,
+ error_type=output_api.PresubmitPromptWarning)
+
+def CheckChangeOnCommit(input_api, output_api):
+ return _CheckXIBSystemAndXcodeVersions(input_api, output_api,
+ error_type=output_api.PresubmitError)
« no previous file with comments | « chrome/app/nibs/OneClickSigninBubble.xib ('k') | chrome/app/nibs/Panel.xib » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698