Add --cc-radar option to webkit-patch bug creation
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2018 17:32:31 +0000 (17:32 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2018 17:32:31 +0000 (17:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190451
<rdar://problem/45176671>

Reviewed by Antoine Quint.

Add a new command line option to automatically
CC radar to new or updated bugs.

* Scripts/webkitpy/tool/commands/commandtest.py:
(CommandsTest.assert_execute_outputs):
* Scripts/webkitpy/tool/commands/upload.py:
(CreateBug.__init__):
(CreateBug.execute):
* Scripts/webkitpy/tool/commands/upload_unittest.py:
(test_prepare_with_cc):
(test_prepare_with_radar):
(test_prepare_with_cc_and_radar):
* Scripts/webkitpy/tool/steps/createbug.py:
(CreateBug.options):
(CreateBug.run):
* Scripts/webkitpy/tool/steps/options.py:
(Options):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/tool/commands/commandtest.py
Tools/Scripts/webkitpy/tool/commands/upload.py
Tools/Scripts/webkitpy/tool/commands/upload_unittest.py
Tools/Scripts/webkitpy/tool/steps/createbug.py
Tools/Scripts/webkitpy/tool/steps/options.py

index 73ce53a..556b246 100644 (file)
@@ -1,3 +1,29 @@
+2018-10-10  Dean Jackson  <dino@apple.com>
+
+        Add --cc-radar option to webkit-patch bug creation
+        https://bugs.webkit.org/show_bug.cgi?id=190451
+        <rdar://problem/45176671>
+
+        Reviewed by Antoine Quint.
+
+        Add a new command line option to automatically
+        CC radar to new or updated bugs.
+
+        * Scripts/webkitpy/tool/commands/commandtest.py:
+        (CommandsTest.assert_execute_outputs):
+        * Scripts/webkitpy/tool/commands/upload.py:
+        (CreateBug.__init__):
+        (CreateBug.execute):
+        * Scripts/webkitpy/tool/commands/upload_unittest.py:
+        (test_prepare_with_cc):
+        (test_prepare_with_radar):
+        (test_prepare_with_cc_and_radar):
+        * Scripts/webkitpy/tool/steps/createbug.py:
+        (CreateBug.options):
+        (CreateBug.run):
+        * Scripts/webkitpy/tool/steps/options.py:
+        (Options):
+
 2018-10-11  Claudio Saavedra  <csaavedra@igalia.com>
 
         [GStreamer] Do not build gstgtk plugins
index 655c33f..217312b 100644 (file)
@@ -34,7 +34,10 @@ from webkitpy.tool.mocktool import MockOptions, MockTool
 class CommandsTest(TestCase):
     def assert_execute_outputs(self, command, args=[], expected_stdout="", expected_stderr="", expected_exception=None, expected_logs=None, options=MockOptions(), tool=MockTool()):
         options.blocks = None
-        options.cc = 'MOCK cc'
+        if getattr(options, "cc", None) == None:
+            options.cc = 'MOCK cc'
+        if getattr(options, "cc_radar", None) == None:
+            options.cc_radar = False
         options.component = 'MOCK component'
         options.confirm = True
         options.email = 'MOCK email'
index c7bca53..8cbcfb0 100644 (file)
@@ -461,6 +461,7 @@ class CreateBug(Command):
     def __init__(self):
         options = [
             steps.Options.cc,
+            steps.Options.cc_radar,
             steps.Options.component,
             make_option("--no-prompt", action="store_false", dest="prompt", default=True, help="Do not prompt for bug title and comment; use commit log instead."),
             make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review."),
@@ -526,6 +527,11 @@ class CreateBug(Command):
         return (bug_title, comment_text)
 
     def execute(self, options, args, tool):
+        if options.cc_radar:
+            if options.cc:
+                options.cc = "webkit-bug-importer@group.apple.com,%s" % options.cc
+            else:
+                options.cc = "webkit-bug-importer@group.apple.com"
         if len(args):
             if (not tool.scm().supports_local_commits()):
                 _log.error("Extra arguments not supported; patch is taken from working directory.")
index afa79fc..5062fc6 100644 (file)
@@ -115,6 +115,31 @@ MOCK add_patch_to_bug: bug_id=50000, description=Patch for landing, mark_for_rev
         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, options=options)
 
+    def test_prepare_with_cc(self):
+        options = MockOptions()
+        options.cc = "a@example.com,b@example.com"
+        options.sort_xcode_project = False
+        options.non_interactive = True
+        expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: a@example.com,b@example.com\n"
+        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs, options=options)
+
+    def test_prepare_with_radar(self):
+        options = MockOptions()
+        options.cc_radar = True
+        options.sort_xcode_project = False
+        options.non_interactive = True
+        expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: webkit-bug-importer@group.apple.com,MOCK cc\n"
+        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs, options=options)
+
+    def test_prepare_with_cc_and_radar(self):
+        options = MockOptions()
+        options.cc = "a@example.com,b@example.com"
+        options.cc_radar = True
+        options.sort_xcode_project = False
+        options.non_interactive = True
+        expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: webkit-bug-importer@group.apple.com,a@example.com,b@example.com\n"
+        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs, options=options)
+
     def test_upload(self):
         options = MockOptions()
         options.cc = None
index 09687ef..c5dc1b1 100644 (file)
@@ -35,6 +35,7 @@ class CreateBug(AbstractStep):
     def options(cls):
         return AbstractStep.options() + [
             Options.cc,
+            Options.cc_radar,
             Options.component,
             Options.blocks,
         ]
@@ -46,6 +47,12 @@ class CreateBug(AbstractStep):
         cc = self._options.cc
         if not cc:
             cc = state.get("bug_cc")
+        cc_radar = self._options.cc_radar
+        if cc_radar:
+            if cc:
+                cc = "webkit-bug-importer@group.apple.com,%s" % cc
+            else:
+                cc = "webkit-bug-importer@group.apple.com"
         if self._options.blocks:
             blocked_bugs = [int(self._options.blocks)]
         else:
index 7259835..7eed2c2 100644 (file)
@@ -36,6 +36,7 @@ class Options(object):
     build = make_option("--build", action="store_true", dest="build", default=False, help="Build and run run-webkit-tests before committing.")
     build_style = make_option("--build-style", action="store", dest="build_style", default=None, help="Whether to build debug, release, or both.")
     cc = make_option("--cc", action="store", type="string", dest="cc", help="Comma-separated list of email addresses to carbon-copy.")
+    cc_radar = make_option("--cc-radar", action="store_true", dest="radar", default=False, help="Add webkit-bug-importer/Radar to the CC list.")
     check_style = make_option("--ignore-style", action="store_false", dest="check_style", default=True, help="Don't check to see if the patch has proper style before uploading.")
     check_style_filter = make_option("--check-style-filter", action="store", type="string", dest="check_style_filter", default=None, help="Filter style-checker rules (see check-webkit-style --help).")
     clean = make_option("--no-clean", action="store_false", dest="clean", default=True, help="Don't check if the working directory is clean before applying patches")