[XCode] webkit-patch should run sort-Xcode-project-file
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 00:25:21 +0000 (00:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 00:25:21 +0000 (00:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174036
<rdar://problem/33732709>

Patch by Stephan Szabo <stephan.szabo@sony.com> on 2017-08-07
Reviewed by Simon Fraser.

* Scripts/webkitpy/common/config/ports.py:
* Scripts/webkitpy/tool/commands/download.py:
* Scripts/webkitpy/tool/commands/download_unittest.py:
* Scripts/webkitpy/tool/commands/upload.py:
* Scripts/webkitpy/tool/commands/upload_unittest.py:
* Scripts/webkitpy/tool/steps/__init__.py:
* Scripts/webkitpy/tool/steps/options.py:
* Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@220372 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/config/ports.py
Tools/Scripts/webkitpy/tool/commands/download.py
Tools/Scripts/webkitpy/tool/commands/download_unittest.py
Tools/Scripts/webkitpy/tool/commands/upload.py
Tools/Scripts/webkitpy/tool/commands/upload_unittest.py
Tools/Scripts/webkitpy/tool/steps/__init__.py
Tools/Scripts/webkitpy/tool/steps/options.py
Tools/Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py [new file with mode: 0644]

index b224796..54fd142 100644 (file)
@@ -1,3 +1,20 @@
+2017-08-07  Stephan Szabo  <stephan.szabo@sony.com>
+
+        [XCode] webkit-patch should run sort-Xcode-project-file
+        https://bugs.webkit.org/show_bug.cgi?id=174036
+        <rdar://problem/33732709>
+
+        Reviewed by Simon Fraser.
+
+        * Scripts/webkitpy/common/config/ports.py:
+        * Scripts/webkitpy/tool/commands/download.py:
+        * Scripts/webkitpy/tool/commands/download_unittest.py:
+        * Scripts/webkitpy/tool/commands/upload.py:
+        * Scripts/webkitpy/tool/commands/upload_unittest.py:
+        * Scripts/webkitpy/tool/steps/__init__.py:
+        * Scripts/webkitpy/tool/steps/options.py:
+        * Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py: Added.
+
 2017-08-07  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Preview Canvas path when viewing a recording
index a3d6dd7..d3dfdf3 100644 (file)
@@ -134,6 +134,9 @@ class DeprecatedPort(object):
         command = self.script_shell_command("run-api-tests")
         return self._append_build_style_flag(command, build_style)
 
+    def run_sort_xcode_project_file_command(self):
+        return self.script_shell_command("sort-Xcode-project-file")
+
 
 class IOSPort(DeprecatedPort):
     port_flag_name = "ios-device"
index 14b55bc..d92770e 100644 (file)
@@ -127,6 +127,7 @@ class LandCowhand(AbstractSequencedCommand):
     name = "land-cowhand"
     help_text = "Prepares a ChangeLog and lands the current working directory diff."
     steps = [
+        steps.SortXcodeProjectFiles,
         steps.PrepareChangeLog,
         steps.EditChangeLog,
         steps.CheckStyle,
index 59c9488..0c9bad0 100644 (file)
@@ -90,6 +90,7 @@ class DownloadCommandsTest(CommandsTest):
         options.architecture = 'MOCK ARCH'
         options.iterate_on_new_tests = 0
         options.group = None
+        options.sort_xcode_project = False
         return options
 
     def test_build(self):
index b3dada5..c592519 100644 (file)
@@ -257,6 +257,7 @@ class Prepare(AbstractSequencedCommand):
     steps = [
         steps.PromptForBugOrTitle,
         steps.CreateBug,
+        steps.SortXcodeProjectFiles,
         steps.PrepareChangeLog,
     ]
 
@@ -275,6 +276,7 @@ class Upload(AbstractPatchUploadingCommand):
         steps.CheckStyle,
         steps.PromptForBugOrTitle,
         steps.CreateBug,
+        steps.SortXcodeProjectFiles,
         steps.PrepareChangeLog,
         steps.EditChangeLog,
         steps.ConfirmDiff,
index 2df9dc2..61f6090 100644 (file)
@@ -103,11 +103,15 @@ MOCK add_patch_to_bug: bug_id=50000, description=Patch for landing, mark_for_rev
         self.assert_execute_outputs(LandSafely(), [50000], expected_logs=expected_logs)
 
     def test_prepare_diff_with_arg(self):
-        self.assert_execute_outputs(Prepare(), [50000])
+        options = MockOptions()
+        options.sort_xcode_project = False
+        self.assert_execute_outputs(Prepare(), [50000], options=options)
 
     def test_prepare(self):
+        options = MockOptions()
+        options.sort_xcode_project = False
         expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: MOCK cc\n"
-        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs)
+        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs, options=options)
 
     def test_upload(self):
         options = MockOptions()
@@ -119,6 +123,7 @@ MOCK add_patch_to_bug: bug_id=50000, description=Patch for landing, mark_for_rev
         options.non_interactive = False
         options.request_commit = False
         options.review = True
+        options.sort_xcode_project = False
         options.suggest_reviewers = False
         expected_logs = """MOCK: user.open_url: file://...
 Was that diff correct?
index 6c9c09a..9cabc4f 100644 (file)
@@ -59,6 +59,7 @@ from webkitpy.tool.steps.promptforbugortitle import PromptForBugOrTitle
 from webkitpy.tool.steps.reopenbugafterrollout import ReopenBugAfterRollout
 from webkitpy.tool.steps.revertrevision import RevertRevision
 from webkitpy.tool.steps.runtests import RunTests
+from webkitpy.tool.steps.sortxcodeprojectfiles import SortXcodeProjectFiles
 from webkitpy.tool.steps.suggestreviewers import SuggestReviewers
 from webkitpy.tool.steps.update import Update
 from webkitpy.tool.steps.updatechangelogswithreviewer import UpdateChangeLogsWithReviewer
index f5e0def..a6ee042 100644 (file)
@@ -57,6 +57,7 @@ class Options(object):
     request_commit = make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Request that the patch be added to the commit queue after review.")
     review = make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review.")
     reviewer = make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER.")
+    sort_xcode_project = make_option("--no-sort-xcode-project", action="store_false", dest="sort_xcode_project", default=True, help="Don't sort modified xcode projects.")
     suggest_reviewers = make_option("--suggest-reviewers", action="store_true", default=False, help="Offer to CC appropriate reviewers.")
     test = make_option("--test", action="store_true", dest="test", default=False, help="Run run-webkit-tests before committing.")
     iterate_on_new_tests = make_option("--iterate-on-new-tests", action="store", type="int", dest="iterate_on_new_tests", default=0, help="Run run-webkit-tests on new tests only before committing, iterating a given number of time.")
diff --git a/Tools/Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py b/Tools/Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py
new file mode 100644 (file)
index 0000000..5c026cc
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (C) 2017 Sony Interactive Entertainment
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Sony Interactive Entertainment nor the names
+# of its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import logging
+import re
+import sys
+
+from webkitpy.common.system.executive import ScriptError
+from webkitpy.tool.steps.abstractstep import AbstractStep
+from webkitpy.tool.steps.options import Options
+
+_log = logging.getLogger(__name__)
+
+
+class SortXcodeProjectFiles(AbstractStep):
+    @classmethod
+    def options(cls):
+        return AbstractStep.options() + [
+            Options.sort_xcode_project,
+        ]
+
+    def run(self, state):
+        if self._options.sort_xcode_project:
+            changed_pbxproj = [file for file in self._changed_files(state) if file.endswith(".pbxproj")]
+            if (len(changed_pbxproj) > 0):
+                args = self._tool.deprecated_port().run_sort_xcode_project_file_command()
+                args = args + changed_pbxproj
+                try:
+                    output = self._tool.executive.run_and_throw_if_fail(args, self._options.quiet, cwd=self._tool.scm().checkout_root)
+                    self.did_modify_checkout(state)
+                except ScriptError, e:
+                    _log.error("Unable to sort modified xcode projects.")
+                    sys.exit(1)