Title: [290148] trunk/Tools
Revision
290148
Author
jbed...@apple.com
Date
2022-02-18 12:04:39 -0800 (Fri, 18 Feb 2022)

Log Message

[git-webkit] Link issue to pull requests (Follow-up fix)
https://bugs.webkit.org/show_bug.cgi?id=236339
<rdar://problem/88657772>

Reviewed by Stephanie Lewis.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.main): Re-open associated closed PRs.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:

Canonical link: https://commits.webkit.org/247487@main

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (290147 => 290148)


--- trunk/Tools/ChangeLog	2022-02-18 19:47:39 UTC (rev 290147)
+++ trunk/Tools/ChangeLog	2022-02-18 20:04:39 UTC (rev 290148)
@@ -1,3 +1,17 @@
+2022-02-18  Jonathan Bedard  <jbed...@apple.com>
+
+        [git-webkit] Link issue to pull requests (Follow-up fix)
+        https://bugs.webkit.org/show_bug.cgi?id=236339
+        <rdar://problem/88657772>
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
+        (PullRequest.main): Re-open associated closed PRs.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
+
 2022-02-18  Sihui Liu  <sihui_...@apple.com>
 
         Add test coverage for data migration introduced in r289878

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (290147 => 290148)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-02-18 19:47:39 UTC (rev 290147)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-02-18 20:04:39 UTC (rev 290148)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='4.3.0',
+    version='4.3.1',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (290147 => 290148)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-02-18 19:47:39 UTC (rev 290147)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-02-18 20:04:39 UTC (rev 290148)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(4, 3, 0)
+version = Version(4, 3, 1)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('jinja2', Version(2, 11, 3)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (290147 => 290148)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-02-18 19:47:39 UTC (rev 290147)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-02-18 20:04:39 UTC (rev 290148)
@@ -258,7 +258,10 @@
                 print('Assigning associated issue to {}'.format(issue.tracker.me()))
             log.info('Checking for pull request link in associated issue...')
             if pr.url and not any([pr.url in comment.content for comment in issue.comments]):
-                issue.add_comment('Pull request: {}'.format(pr.url))
+                if issue.opened:
+                    issue.add_comment('Pull request: {}'.format(pr.url))
+                else:
+                    issue.open(why='Re-opening for pull request {}'.format(pr.url))
                 print('Posted pull request link to {}'.format(issue.link))
 
         if pr.url:

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (290147 => 290148)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2022-02-18 19:47:39 UTC (rev 290147)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2022-02-18 20:04:39 UTC (rev 290148)
@@ -549,6 +549,59 @@
             ],
         )
 
+    def test_github_reopen_bugzilla(self):
+        with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, bmocks.Bugzilla(
+            self.BUGZILLA.split('://')[-1],
+            issues=bmocks.ISSUES,
+            environment=Environment(
+                BUGS_EXAMPLE_COM_USERNAME='tcontribu...@example.com',
+                BUGS_EXAMPLE_COM_PASSWORD='password',
+            )), patch(
+                'webkitbugspy.Tracker._trackers', [bugzilla.Tracker(self.BUGZILLA)],
+        ), mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn():
+
+            Tracker.instance().issue(1).close(why='Looks like we will not get to this')
+            repo.commits['eng/pr-branch'] = [Commit(
+                hash='06de5d56554e693db72313f4ca1fb969c30b8ccb',
+                branch='eng/pr-branch',
+                author=dict(name='Tim Contributor', emails=['tcontribu...@example.com']),
+                identifier="5.1@eng/pr-branch",
+                timestamp=int(time.time()),
+                message='[Testing] Existing commit\nbugs.example.com/show_bug.cgi?id=1'
+            )]
+            repo.head = repo.commits['eng/pr-branch'][-1]
+            self.assertEqual(0, program.main(
+                args=('pull-request', '-v', '--no-history'),
+                path=self.path,
+            ))
+
+            self.assertEqual(
+                Tracker.instance().issue(1).comments[-1].content,
+                'Re-opening for pull request https://github.example.com/WebKit/WebKit/pull/1',
+            )
+
+        self.assertEqual(
+            captured.stdout.getvalue(),
+            "Created 'PR 1 | [Testing] Existing commit'!\n"
+            'Posted pull request link to https://bugs.example.com/show_bug.cgi?id=1\n'
+            'https://github.example.com/WebKit/WebKit/pull/1\n',
+        )
+        self.assertEqual(captured.stderr.getvalue(), '')
+        log = captured.root.log.getvalue().splitlines()
+        self.assertEqual(
+            [line for line in log if 'Mock process' not in line], [
+                '    Found 1 commit...',
+                "Using committed changes...",
+                "Rebasing 'eng/pr-branch' on 'main'...",
+                "Rebased 'eng/pr-branch' on 'main!'",
+                "    Found 1 commit...",
+                "Pushing 'eng/pr-branch' to 'fork'...",
+                "Creating pull-request for 'eng/pr-branch'...",
+                'Checking issue assignee...',
+                'Checking for pull request link in associated issue...',
+            ],
+        )
+
     def test_bitbucket(self):
         with OutputCapture(level=logging.INFO) as captured, mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
             remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
@@ -779,7 +832,54 @@
             ],
         )
 
+    def test_bitbucket_reopen_radar(self):
+        with OutputCapture(level=logging.INFO) as captured, mocks.remote.BitBucket() as remote, mocks.local.Git(
+            self.path, remote='ssh://git@{}/{}/{}.git'.format(remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3]),
+        ) as repo, mocks.local.Svn(), Environment(RADAR_USERNAME='tcontributor'), bmocks.Radar(issues=bmocks.ISSUES), patch('webkitbugspy.Tracker._trackers', [radar.Tracker()]):
 
+            Tracker.instance().issue(1).close(why='Looks like we will not get to this')
+            repo.commits['eng/pr-branch'] = [Commit(
+                hash='06de5d56554e693db72313f4ca1fb969c30b8ccb',
+                branch='eng/pr-branch',
+                author=dict(name='Tim Contributor', emails=['tcontribu...@example.com']),
+                identifier="5.1@eng/pr-branch",
+                timestamp=int(time.time()),
+                message='<rdar://problem/1> [Testing] Existing commit\n'
+            )]
+            repo.head = repo.commits['eng/pr-branch'][-1]
+            self.assertEqual(0, program.main(
+                args=('pull-request', '-v', '--no-history'),
+                path=self.path,
+            ))
+
+            self.assertEqual(
+                Tracker.instance().issue(1).comments[-1].content,
+                'Re-opening for pull request https://bitbucket.example.com/projects/WEBKIT/repos/webkit/pull-requests/1/overview',
+            )
+
+        self.assertEqual(
+            captured.stdout.getvalue(),
+            "Created 'PR 1 | <rdar://problem/1> [Testing] Existing commit'!\n"
+            'Posted pull request link to <rdar://1>\n'
+            'https://bitbucket.example.com/projects/WEBKIT/repos/webkit/pull-requests/1/overview\n',
+        )
+        self.assertEqual(captured.stderr.getvalue(), '')
+        log = captured.root.log.getvalue().splitlines()
+        self.assertEqual(
+            [line for line in log if 'Mock process' not in line], [
+                '    Found 1 commit...',
+                "Using committed changes...",
+                "Rebasing 'eng/pr-branch' on 'main'...",
+                "Rebased 'eng/pr-branch' on 'main!'",
+                "    Found 1 commit...",
+                "Pushing 'eng/pr-branch' to 'origin'...",
+                "Creating pull-request for 'eng/pr-branch'...",
+                'Checking issue assignee...',
+                'Checking for pull request link in associated issue...',
+            ],
+        )
+
+
 class TestNetworkPullRequestGitHub(unittest.TestCase):
     remote = 'https://github.example.com/WebKit/WebKit'
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to