Title: [285035] trunk/Tools
Revision
285035
Author
[email protected]
Date
2021-10-29 09:50:16 -0700 (Fri, 29 Oct 2021)

Log Message

[webkitscmpy] Assign PR to author
https://bugs.webkit.org/show_bug.cgi?id=232348
<rdar://problem/84685313>

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py:
(GitHub.request): Add assignees.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
(GitHub.PRGenerator.create): Assign created PR to it's author.
(GitHub.PRGenerator.update): Assign modified PR to it's editor.
* Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py: Add assignees.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (285034 => 285035)


--- trunk/Tools/ChangeLog	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/ChangeLog	2021-10-29 16:50:16 UTC (rev 285035)
@@ -1,3 +1,20 @@
+2021-10-29  Jonathan Bedard  <[email protected]>
+
+        [webkitscmpy] Assign PR to author
+        https://bugs.webkit.org/show_bug.cgi?id=232348
+        <rdar://problem/84685313>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py:
+        (GitHub.request): Add assignees.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
+        (GitHub.PRGenerator.create): Assign created PR to it's author.
+        (GitHub.PRGenerator.update): Assign modified PR to it's editor.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py: Add assignees.
+
 2021-10-29  Alex Christensen  <[email protected]>
 
         Re-enable two AppPrivacyReport tests

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (285034 => 285035)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-10-29 16:50:16 UTC (rev 285035)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='2.2.20',
+    version='2.2.21',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (285034 => 285035)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-10-29 16:50:16 UTC (rev 285035)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(2, 2, 20)
+version = Version(2, 2, 21)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('jinja2', Version(2, 11, 3)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py (285034 => 285035)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py	2021-10-29 16:50:16 UTC (rev 285035)
@@ -411,6 +411,11 @@
             pr['user'] = dict(login=auth.username)
             pr['_links'] = dict(issue=dict(href=''.format(self.api_remote, pr['number'])))
             self.pull_requests.append(pr)
+            if int(pr['number']) not in self.issues:
+                self.issues[int(pr['number'])] = dict(
+                    comments=[],
+                    assignees=[],
+                )
             return mocks.Response.fromJson(pr, url=""
 
         # Update specifically
@@ -444,6 +449,9 @@
                     body=json.get('body', ''),
                 ))
                 return mocks.Response.fromJson(issue['comments'], url=""
+            if method == 'POST' and stripped_url.split('/')[6] == 'assignees':
+                self.issues[number]['assignees'] = {'login': name for name in json.get('assignees', [])}
+                return mocks.Response.fromJson(issue['assignees'], url=""
             return mocks.Response.create404(url)
 
         return mocks.Response.create404(url)

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py (285034 => 285035)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py	2021-10-29 16:50:16 UTC (rev 285035)
@@ -104,8 +104,19 @@
             )
             if response.status_code // 100 != 2:
                 return None
-            return self.PullRequest(response.json())
+            result = self.PullRequest(response.json())
 
+            # FIXME: Move this to bug tracking library
+            issue = result._metadata.get('issue')
+            if not issue or requests.post(
+                '{}/assignees'.format(issue),
+                auth=HTTPBasicAuth(*self.repository.credentials()),
+                headers=dict(Accept='application/vnd.github.v3+json'),
+                json=dict(assignees=[user]),
+            ).status_code // 100 != 2:
+                sys.stderr.write("Failed to assign '{}' to '{}'\n".format(result, user))
+            return result
+
         def update(self, pull_request, head=None, title=None, body=None, commits=None, base=None, opened=None):
             if not isinstance(pull_request, PullRequest):
                 raise ValueError("Expected 'pull_request' to be of type '{}' not '{}'".format(PullRequest, type(pull_request)))
@@ -155,6 +166,18 @@
                 issue=data.get('_links', {}).get('issue', {}).get('href'),
             )
 
+            # FIXME: Move this to bug tracking library
+            assignees = [node.get('login') for node in data.get('assignees', []) if node.get('login')]
+            if user not in assignees:
+                issue = pull_request._metadata.get('issue')
+                if not issue or requests.post(
+                        '{}/assignees'.format(issue),
+                        auth=HTTPBasicAuth(*self.repository.credentials()),
+                        headers=dict(Accept='application/vnd.github.v3+json'),
+                        json=dict(assignees=assignees + [user]),
+                ).status_code // 100 != 2:
+                    sys.stderr.write("Failed to assign '{}' to '{}'\n".format(pull_request, user))
+
             return pull_request
 
         def _contributor(self, username):

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


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2021-10-29 16:48:20 UTC (rev 285034)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2021-10-29 16:50:16 UTC (rev 285035)
@@ -445,6 +445,12 @@
             sreviewer=Contributor('Suspicious Reviewer', ['[email protected]'], github='sreviewer'),
             tcontributor=Contributor('Tim Contributor', ['[email protected]']),
         )
+        result.issues = {
+            1: dict(
+                comments=[],
+                assignees=[],
+            )
+        }
         result.pull_requests = [dict(
             number=1,
             state='open',
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to