Title: [288312] trunk/Tools
Revision
288312
Author
[email protected]
Date
2022-01-20 11:48:18 -0800 (Thu, 20 Jan 2022)

Log Message

[webkitbugspy] Support automated comments
https://bugs.webkit.org/show_bug.cgi?id=235371
<rdar://problem/87783426>

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitbugspy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py:
(Tracker.user): Add potential credentials to requests.
(Tracker.credentials): Explicitly call credentials from webkitcorepy.
(Tracker._login_arguments): Create login query from credentials.
(Tracker.me): Return user based on credentials.
(Tracker.populate): Add potential credentials to requests.
(Tracker.add_comment): Add comment to bugzilla issue.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py:
(Tracker.me): Return user based on credentials.
(Tracker.add_comment): Add comment to GitHub issue.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py:
(Issue.add_comment): Base class.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/base.py:
(Base.add): We don't want to edit the original list of comments.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py:
(Bugzilla.__init__): Add optional Environment mock.
(Bugzilla.__enter__): Enter Environment mock.
(Bugzilla.__exit__): Exit Environment mock.
(Bugzilla._user): Use jsonlib instead of json.
(Bugzilla._user_for_credentials): Convert a credential string into
a User object.
(Bugzilla._issue): Use jsonlib instead of json.
(Bugzilla._see_also): Ditto.
(Bugzilla._comments): Ditto.
(Bugzilla._post_comment): Update mock issue database with posted comment.
(Bugzilla.request): Add credentials to each request, handle comment POST request.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py:
(GitHub.__init__): Add optional Environment mock.
(GitHub.__enter__): Enter Environment mock.
(GitHub.__exit__): Exit Environment mock.
(GitHub._post_comment): Update mock issue database with posted comment.
(GitHub.request): Handle comment POST request.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py:
(AppleDirectoryQuery.user_entry_for_attribute_value): Map AppleConnect username
to user.
(RadarModel.CollectionProperty.__init__): Pass parent model in.
(RadarModel.CollectionProperty.add): Add an element to the collection.
(RadarModel.__init__): Pass self into CollectionProperty.
(RadarModel.commit_changes): Update mock issue database with issue contents.
(RadarClient.__init__): Accept authentication_strategy.
(Radar.AuthenticationStrategySystemAccount.__init__): Save username.
(Radar.AuthenticationStrategySystemAccount.username): Return username.
(Radar.AuthenticationStrategySPNego.username): Assume username from environment.
(Radar.DiagnosisEntry): Moved from RadarModel.DiagnosisEntry.
(Radar.transform_user): Add AppleConnect email.
(Radar.__init__): Pass authentication_strategy to RadarClient.
(RadarModel.DiagnosisEntry): Moved to Radar.DiagnosisEntry.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py:
(Tracker.user): Support queries by AppleConnect username.
(Tracker.me): Use authentication to determine the logged in user.
(Tracker.add_comment): Add comment to Radar.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py:
(TestBugzilla.test_reference_parse): Use add_comment.
(TestBugzilla.test_me): Added.
(TestBugzilla.test_add_comment): Added.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py:
(TestGitHub.test_watcher_parse): Use add_comment.
(TestGitHub.test_reference_parse): Ditto.
(TestGitHub.test_me): Added.
(TestGitHub.test_add_comment): Added.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py:
(TestRadar): Renamed from TestGitHub.
(TestRadar.test_reference_parse): Use add_comment.
(TestRadar.test_me): Added.
(TestRadar.test_add_comment): Added.
(TestGitHub): Renamed TestRadar.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py:
(Tracker.me): Added.
(Tracker.add_comment): Added.
* Tools/Scripts/libraries/webkitcorepy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py: Export mock environment, bump version.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/environment.py: Added.
(Environment): Mock os.environ and reset credential cache.

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

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (288311 => 288312)


--- trunk/Tools/ChangeLog	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/ChangeLog	2022-01-20 19:48:18 UTC (rev 288312)
@@ -1,3 +1,87 @@
+2022-01-19  Jonathan Bedard  <[email protected]>
+
+        [webkitbugspy] Support automated comments
+        https://bugs.webkit.org/show_bug.cgi?id=235371
+        <rdar://problem/87783426>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitbugspy/setup.py: Bump version.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py:
+        (Tracker.user): Add potential credentials to requests.
+        (Tracker.credentials): Explicitly call credentials from webkitcorepy. 
+        (Tracker._login_arguments): Create login query from credentials.
+        (Tracker.me): Return user based on credentials.
+        (Tracker.populate): Add potential credentials to requests.
+        (Tracker.add_comment): Add comment to bugzilla issue.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/github.py:
+        (Tracker.me): Return user based on credentials.
+        (Tracker.add_comment): Add comment to GitHub issue.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/issue.py:
+        (Issue.add_comment): Base class.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/base.py:
+        (Base.add): We don't want to edit the original list of comments.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py:
+        (Bugzilla.__init__): Add optional Environment mock.
+        (Bugzilla.__enter__): Enter Environment mock.
+        (Bugzilla.__exit__): Exit Environment mock.
+        (Bugzilla._user): Use jsonlib instead of json.
+        (Bugzilla._user_for_credentials): Convert a credential string into
+        a User object.
+        (Bugzilla._issue): Use jsonlib instead of json.
+        (Bugzilla._see_also): Ditto.
+        (Bugzilla._comments): Ditto.
+        (Bugzilla._post_comment): Update mock issue database with posted comment.
+        (Bugzilla.request): Add credentials to each request, handle comment POST request.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py:
+        (GitHub.__init__): Add optional Environment mock.
+        (GitHub.__enter__): Enter Environment mock.
+        (GitHub.__exit__): Exit Environment mock.
+        (GitHub._post_comment): Update mock issue database with posted comment.
+        (GitHub.request): Handle comment POST request.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py:
+        (AppleDirectoryQuery.user_entry_for_attribute_value): Map AppleConnect username
+        to user.
+        (RadarModel.CollectionProperty.__init__): Pass parent model in.
+        (RadarModel.CollectionProperty.add): Add an element to the collection.
+        (RadarModel.__init__): Pass self into CollectionProperty.
+        (RadarModel.commit_changes): Update mock issue database with issue contents.
+        (RadarClient.__init__): Accept authentication_strategy.
+        (Radar.AuthenticationStrategySystemAccount.__init__): Save username.
+        (Radar.AuthenticationStrategySystemAccount.username): Return username.
+        (Radar.AuthenticationStrategySPNego.username): Assume username from environment.
+        (Radar.DiagnosisEntry): Moved from RadarModel.DiagnosisEntry.
+        (Radar.transform_user): Add AppleConnect email.
+        (Radar.__init__): Pass authentication_strategy to RadarClient.
+        (RadarModel.DiagnosisEntry): Moved to Radar.DiagnosisEntry.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/radar.py:
+        (Tracker.user): Support queries by AppleConnect username.
+        (Tracker.me): Use authentication to determine the logged in user.
+        (Tracker.add_comment): Add comment to Radar.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py:
+        (TestBugzilla.test_reference_parse): Use add_comment.
+        (TestBugzilla.test_me): Added.
+        (TestBugzilla.test_add_comment): Added.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py:
+        (TestGitHub.test_watcher_parse): Use add_comment.
+        (TestGitHub.test_reference_parse): Ditto.
+        (TestGitHub.test_me): Added.
+        (TestGitHub.test_add_comment): Added.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py:
+        (TestRadar): Renamed from TestGitHub.
+        (TestRadar.test_reference_parse): Use add_comment.
+        (TestRadar.test_me): Added.
+        (TestRadar.test_add_comment): Added.
+        (TestGitHub): Renamed TestRadar.
+        * Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py:
+        (Tracker.me): Added.
+        (Tracker.add_comment): Added.
+        * Scripts/libraries/webkitcorepy/setup.py: Bump version.
+        * Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py: Export mock environment, bump version.
+        * Scripts/libraries/webkitcorepy/webkitcorepy/mocks/environment.py: Added.
+        (Environment): Mock os.environ and reset credential cache.
+
 2022-01-20  Alex Christensen  <[email protected]>
 
         [ iOS15 ] TestWebKitAPI.WebKit.ServerTrust and TestWebKitAPI.WebKit.FastServerTrust tests timing out

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/setup.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/setup.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/setup.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -30,7 +30,7 @@
 
 setup(
     name='webkitbugspy',
-    version='0.0.2',
+    version='0.1.0',
     description='Library containing a shared API for various bug trackers.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 0, 2)
+version = Version(0, 1, 0)
 
 from .user import User
 from .issue import Issue

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 Apple Inc. All rights reserved.
+# Copyright (C) 2021-2022 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -21,16 +21,16 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import calendar
-import os
 import re
 import requests
 import sys
+import time
+import webkitcorepy
 
 from .issue import Issue
 from .tracker import Tracker as GenericTracker
 
 from datetime import datetime
-from webkitcorepy import credentials, decorators, OutputCapture
 
 
 class Tracker(GenericTracker):
@@ -61,7 +61,13 @@
 
         if not username and not email:
             raise RuntimeError("Failed to find username for '{}'".format(name))
-        response = requests.get('{}/rest/user?names={}'.format(self.url, username or email or name))
+        response = requests.get('{url}/rest/user{query}'.format(
+            url=""
+            query=self._login_arguments(
+                required=False,
+                query='names={name}'.format(name=username or email or name),
+            ),
+        ))
         response = response.json().get('users') if response.status_code // 100 == 2 else None
         if not response:
             return self.users.create(
@@ -84,12 +90,27 @@
         return None
 
     def credentials(self, required=True):
-        return credentials(
+        return webkitcorepy.credentials(
             url=""
             required=required,
             prompt=self.url.split('//')[-1],
         )
 
+    def _login_arguments(self, required=False, query=None):
+        username, password = self.credentials(required=required)
+        if not username or not password:
+            return '?{}'.format(query) if query else ''
+        return '?login={username}&password={password}{query}'.format(
+            username=username,
+            password=password,
+            query='&{}'.format(query) if query else '',
+        )
+
+    @webkitcorepy.decorators.Memoize()
+    def me(self):
+        username, _ = self.credentials(required=True)
+        return self.user(username=username)
+
     def issue(self, id):
         return Issue(id=int(id), tracker=self)
 
@@ -97,7 +118,7 @@
         issue._link = '{}/show_bug.cgi?id={}'.format(self.url, issue.id)
 
         if member in ['title', 'timestamp', 'creator', 'opened', 'assignee', 'watchers']:
-            response = requests.get('{}/rest/bug/{}'.format(self.url, issue.id))
+            response = requests.get('{}/rest/bug/{}{}'.format(self.url, issue.id, self._login_arguments(required=False)))
             response = response.json().get('bugs', []) if response.status_code == 200 else None
             if response:
                 response = response[0]
@@ -128,7 +149,7 @@
                 sys.stderr.write("Failed to fetch '{}'\n".format(issue.link))
 
         if member in ['description', 'comments']:
-            response = requests.get('{}/rest/bug/{}/comment'.format(self.url, issue.id))
+            response = requests.get('{}/rest/bug/{}/comment{}'.format(self.url, issue.id, self._login_arguments(required=False)))
             if response.status_code == 200:
                 response = response.json().get('bugs', {}).get(str(issue.id), {}).get('comments', None)
             else:
@@ -158,7 +179,10 @@
                     issue._references.append(candidate)
                     refs.add(candidate.link)
 
-            response = requests.get('{}/rest/bug/{}?include_fields=see_also'.format(self.url, issue.id))
+            response = requests.get('{url}/rest/bug/{id}{query}'.format(
+                url="" id=issue.id,
+                query=self._login_arguments(required=False, query='include_fields=see_also'),
+            ))
             response = response.json().get('bugs', []) if response.status_code == 200 else None
             if response:
                 for link in response[0].get('see_also', []):
@@ -171,3 +195,23 @@
                 sys.stderr.write("Failed to fetch related issues for '{}'\n".format(issue.link))
 
         return issue
+
+    def add_comment(self, issue, text):
+        response = requests.post(
+            '{}/rest/bug/{}/comment{}'.format(self.url, issue.id, self._login_arguments(required=True)),
+            json=dict(comment=text),
+        )
+        if response.status_code // 100 != 2:
+            sys.stderr.write("Failed to add comment to '{}'\n".format(issue))
+            return None
+
+        result = Issue.Comment(
+            user=self.me(),
+            timestamp=int(time.time()),
+            content=text,
+        )
+        if not issue._comments:
+            self.populate(issue, 'comments')
+        issue._comments.append(result)
+
+        return result

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -24,6 +24,7 @@
 import re
 import requests
 import sys
+import time
 import webkitcorepy
 
 from .issue import Issue
@@ -151,6 +152,11 @@
             emails=[data.get('email')],
         )
 
+    @webkitcorepy.decorators.Memoize()
+    def me(self):
+        username, _ = self.credentials(required=True)
+        return self.user(username=username)
+
     def issue(self, id):
         return Issue(id=int(id), tracker=self)
 
@@ -244,3 +250,36 @@
                     refs.add(candidate.link)
 
         return issue
+
+    def add_comment(self, issue, text):
+        response = requests.post(
+            '{api_url}/repos/{owner}/{name}/issues/{id}/comments'.format(
+                api_url=self.api_url,
+                owner=self.owner,
+                name=self.name,
+                id=issue.id,
+            ),
+            auth=HTTPBasicAuth(*self.credentials(required=True)),
+            headers=dict(Accept='application/vnd.github.v3+json'),
+            json=dict(body=text),
+        )
+        if response.status_code // 100 != 2:
+            sys.stderr.write("Failed to add comment to '{}'\n".format(issue))
+            return None
+
+        data = ""
+        tm = data.get('updated_at', data.get('created_at'))
+        if tm:
+            tm = int(calendar.timegm(datetime.strptime(tm, '%Y-%m-%dT%H:%M:%SZ').timetuple()))
+        else:
+            tm = time.time()
+
+        result = Issue.Comment(
+            user=self.user(username=data.get('user', {}).get('login')),
+            timestamp=tm,
+            content=data.get('body'),
+        )
+        if not issue._comments:
+            self.populate(issue, 'comments')
+        issue._comments.append(result)
+        return result

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -132,6 +132,9 @@
             self.tracker.populate(self, 'references')
         return self._references or []
 
+    def add_comment(self, text):
+        return self.tracker.add_comment(self, text)
+
     def __hash__(self):
         return hash(self.link)
 

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/base.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/base.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/base.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -19,6 +19,7 @@
 # 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 copy
 
 from webkitbugspy import User
 
@@ -56,4 +57,4 @@
             if user:
                 self.users.add(type(self).transform_user(user))
 
-        self.issues[id] = {key: value for key, value in bug_data.items()}
+        self.issues[id] = copy.deepcopy(bug_data)

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -22,15 +22,17 @@
 
 import json
 import re
+import time
 
 from .base import Base
 
-from webkitbugspy import User
+from webkitbugspy import User, Issue
 from webkitcorepy import mocks
 
 
 class Bugzilla(Base, mocks.Requests):
     top = None
+    CREDENTIAL_RE = re.compile(r'\??login=(?P<login>\S+)\&password=(?P<password>\S+)\&?$')
 
     @classmethod
     def time_string(cls, timestamp):
@@ -45,10 +47,29 @@
             emails=user.emails,
         )
 
-    def __init__(self, hostname='bugs.example.com', users=None, issues=None):
+    def __init__(self, hostname='bugs.example.com', users=None, issues=None, environment=None):
         Base.__init__(self, users=users, issues=issues)
         mocks.Requests.__init__(self, hostname)
+        self._comment_count = 1
 
+        prefix = self.hosts[0].replace('.', '_').upper()
+        self._environment = environment or mocks.Environment(**{
+            '{}_USERNAME'.format(prefix): 'usernmae',
+            '{}_PASSWORD'.format(prefix): 'password',
+        })
+
+        for issue in self.issues.values():
+            self._comment_count += (1 + len(issue.get('comments', [])))
+
+    def __enter__(self):
+        self._environment.__enter__()
+        return super(Bugzilla, self).__enter__()
+
+    def __exit__(self, *args, **kwargs):
+        result = super(Bugzilla, self).__exit__(*args, **kwargs)
+        self._environment.__exit__(*args, **kwargs)
+        return result
+
     def _user(self, url, username):
         user = self.users[username]
         if not user:
@@ -69,6 +90,14 @@
             )],
         ), url=""
 
+    def _user_for_credentials(self, credentials):
+        if not credentials:
+            return None
+        match = self.CREDENTIAL_RE.match(credentials)
+        if not match:
+            return None
+        return self.users.get(match.group('login'))
+
     def _issue(self, url, id):
         if id not in self.issues:
             return mocks.Response(
@@ -167,6 +196,28 @@
             ])},
         ), url=""
 
+    def _post_comment(self, url, id, credentials, data):
+        comment = data.get('comment', None)
+        user = self._user_for_credentials(credentials)
+
+        if not user:
+            return mocks.Response(status_code=401, url=""
+        if id not in self.issues:
+            return mocks.Response.create404(url=""
+        if not comment:
+            return mocks.Response(status_code=400, url=""
+
+        self.issues[id]['comments'].append(
+            Issue.Comment(user=user, timestamp=int(time.time()), content=comment),
+        )
+
+        self._comment_count += 1
+        return mocks.Response(
+            status_code=201,
+            text=json.dumps(dict(id=self._comment_count)),
+            url=""
+        )
+
     def request(self, method, url, data="" params=None, auth=None, json=None, **kwargs):
         if not url.startswith('http://') and not url.startswith('https://'):
             return mocks.Response.create404(url)
@@ -173,20 +224,22 @@
 
         stripped_url = url.split('://')[-1]
 
-        match = re.match(r'{}/rest/user\?names=(?P<username>\S+)$'.format(self.hosts[0]), stripped_url)
+        match = re.match(r'{}/rest/user\?(?P<credentials>login=\S+\&password=\S+\&)?names=(?P<username>\S+)$'.format(self.hosts[0]), stripped_url)
         if match and method == 'GET':
             return self._user(url, match.group('username'))
 
-        match = re.match(r'{}/rest/bug/(?P<id>\d+)$'.format(self.hosts[0]), stripped_url)
+        match = re.match(r'{}/rest/bug/(?P<id>\d+)(?P<credentials>\?login=\S+\&password=\S+)?$'.format(self.hosts[0]), stripped_url)
         if match and method == 'GET':
             return self._issue(url, int(match.group('id')))
 
-        match = re.match(r'{}/rest/bug/(?P<id>\d+)\?include_fields=see_also$'.format(self.hosts[0]), stripped_url)
+        match = re.match(r'{}/rest/bug/(?P<id>\d+)\?(?P<credentials>login=\S+\&password=\S+\&)?include_fields=see_also$'.format(self.hosts[0]), stripped_url)
         if match and method == 'GET':
             return self._see_also(url, int(match.group('id')))
 
-        match = re.match(r'{}/rest/bug/(?P<id>\d+)/comment$'.format(self.hosts[0]), stripped_url)
+        match = re.match(r'{}/rest/bug/(?P<id>\d+)/comment(?P<credentials>\?login=\S+\&password=\S+)?$'.format(self.hosts[0]), stripped_url)
         if match and method == 'GET':
             return self._comments(url, int(match.group('id')))
+        if match and method == 'POST':
+            return self._post_comment(url, int(match.group('id')), match.group('credentials'), json)
 
         return mocks.Response.create404(url)

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -21,12 +21,12 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import json
-import os
 import re
+import time
 
 from .base import Base
 
-from webkitbugspy import User
+from webkitbugspy import User, Issue
 from webkitcorepy import mocks
 
 
@@ -46,7 +46,7 @@
         from datetime import datetime, timedelta
         return datetime.utcfromtimestamp(timestamp - timedelta(hours=7).seconds).strftime('%Y-%m-%dT%H:%M:%SZ')
 
-    def __init__(self, hostname='github.example.com/WebKit/WebKit', users=None, issues=None):
+    def __init__(self, hostname='github.example.com/WebKit/WebKit', users=None, issues=None, environment=None):
         hostname, repo = hostname.split('/', 1)
         self.api_host = 'api.{hostname}/repos/{repo}'.format(hostname=hostname, repo=repo)
 
@@ -53,28 +53,19 @@
         Base.__init__(self, users=users, issues=issues)
         mocks.Requests.__init__(self, hostname, 'api.{}'.format(hostname))
 
-        self._environment = None
+        prefix = self.hosts[0].replace('.', '_').upper()
+        self._environment = environment or mocks.Environment(**{
+            '{}_USERNAME'.format(prefix): 'usernmae',
+            '{}_TOKEN'.format(prefix): 'token',
+        })
 
     def __enter__(self):
-        prefix = self.hosts[0].replace('.', '_').upper()
-        username_key = '{}_USERNAME'.format(prefix)
-        token_key = '{}_TOKEN'.format(prefix)
-        self._environment = {
-            username_key: os.environ.get(username_key),
-            token_key: os.environ.get(token_key),
-        }
-        os.environ[username_key] = 'username'
-        os.environ[token_key] = 'token'
-
+        self._environment.__enter__()
         return super(GitHub, self).__enter__()
 
     def __exit__(self, *args, **kwargs):
         result = super(GitHub, self).__exit__(*args, **kwargs)
-        for key in self._environment.keys():
-            if self._environment[key]:
-                os.environ[key] = self._environment[key]
-            else:
-                del os.environ[key]
+        self._environment.__exit__(*args, **kwargs)
         return result
 
     def _user(self, url, username):
@@ -124,6 +115,29 @@
             ) for comment in issue['comments']
         ])
 
+    def _post_comment(self, url, id, credentials, data):
+        user = self.users.get(credentials.username) if credentials else None
+        body = data.get('body')
+
+        if not user or id not in self.issues:
+            return mocks.Response.create404(url=""
+        if not body:
+            return mocks.Response(status_code=400, url=""
+
+        timestamp = time.time()
+        self.issues[id]['comments'].append(
+            Issue.Comment(user=user, timestamp=int(timestamp), content=body),
+        )
+
+        return mocks.Response.fromJson(
+            url="" data=""
+                body=body,
+                user=dict(login=user.username),
+                updated_at=self.time_string(timestamp),
+                created_at=self.time_string(timestamp),
+            ),
+        )
+
     def _timelines(self, url, id):
         if id not in self.issues:
             return mocks.Response(
@@ -163,6 +177,8 @@
         match = re.match(r'{}/issues/(?P<id>\d+)/comments$'.format(self.api_host), stripped_url)
         if match and method == 'GET':
             return self._comments(url, int(match.group('id')))
+        if match and method == 'POST':
+            return self._post_comment(url, int(match.group('id')), auth, json)
 
         match = re.match(r'{}/issues/(?P<id>\d+)/timeline$'.format(self.api_host), stripped_url)
         if match and method == 'GET':

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -20,9 +20,13 @@
 # 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 calendar
+import os
+import time
+
 from .base import Base
 
-from webkitbugspy import User
+from webkitbugspy import User, Issue
 from webkitcorepy import string_utils
 from webkitcorepy.mocks import ContextStack
 
@@ -43,7 +47,7 @@
         return self.user_entry_for_attribute_value('dsid', dsid)
 
     def user_entry_for_attribute_value(self, name, value):
-        if name not in ('cn', 'dsid', 'mail'):
+        if name not in ('cn', 'dsid', 'mail', 'uid'):
             raise ValueError("'{}' is not a valid user attribute value".format(name))
         found = self.parent.users.get(value)
         if not found:
@@ -52,7 +56,7 @@
             return None
         if name == 'dsid' and value != found.username:
             return None
-        if name == 'mail' and value not in found.emails:
+        if name in ('mail', 'uid') and value not in found.emails:
             return None
         return AppleDirectoryUserEntry(found)
 
@@ -70,13 +74,29 @@
             self.person = RadarModel.Person(user)
 
     class CollectionProperty(object):
-        def __init__(self, *properties):
-            self._properties = properties
+        def __init__(self, model, *properties):
+            self.model = model
+            self._properties = list(properties)
 
         def items(self, type=None):
             for property in self._properties:
                 yield property
 
+        def add(self, item):
+            from datetime import datetime, timedelta
+
+            username = self.model.client.authentication_strategy.username()
+            if username:
+                by = RadarModel.CommentAuthor(self.model.client.parent.users['{}@APPLECONNECT.APPLE.COM'.format(username)])
+            else:
+                by = None
+
+            self._properties.append(Radar.DiagnosisEntry(
+                text=item.text,
+                addedAt=datetime.utcfromtimestamp(int(time.time())),
+                addedBy=by,
+            ))
+
     class DescriptionEntry(object):
         def __init__(self, text):
             self.text = text
@@ -86,12 +106,6 @@
             self.name = user.name
             self.email = user.email
 
-    class DiagnosisEntry(object):
-        def __init__(self, text, addedAt, addedBy):
-            self.text = text
-            self.addedAt = addedAt
-            self.addedBy = addedBy
-
     def __init__(self, client, issue):
         from datetime import datetime, timedelta
 
@@ -101,17 +115,17 @@
         self.id = issue['id']
         self.createdAt = datetime.utcfromtimestamp(issue['timestamp'] - timedelta(hours=7).seconds)
         self.assignee = self.Person(Radar.transform_user(issue['assignee']))
-        self.description = self.CollectionProperty(self.DescriptionEntry(issue['description']))
+        self.description = self.CollectionProperty(self, self.DescriptionEntry(issue['description']))
         self.state = 'Investigate' if issue['opened'] else 'Verify'
         self.originator = self.Person(Radar.transform_user(issue['creator']))
-        self.diagnosis = self.CollectionProperty(*[
-            self.DiagnosisEntry(
+        self.diagnosis = self.CollectionProperty(self, *[
+            Radar.DiagnosisEntry(
                 text=comment.content,
                 addedAt=datetime.utcfromtimestamp(comment.timestamp - timedelta(hours=7).seconds),
                 addedBy=self.CommentAuthor(Radar.transform_user(comment.user)),
             ) for comment in issue.get('comments', [])
         ])
-        self.cc_memberships = self.CollectionProperty(*[
+        self.cc_memberships = self.CollectionProperty(self, *[
             self.CCMembership(Radar.transform_user(watcher)) for watcher in issue.get('watchers', [])
         ])
 
@@ -121,10 +135,20 @@
             if ref:
                 yield ref
 
+    def commit_changes(self):
+        self.client.parent.issues[self.id]['comments'] = [
+            Issue.Comment(
+                user=self.client.parent.users[entry.addedBy.email],
+                timestamp=int(calendar.timegm(entry.addedAt.timetuple())),
+                content=entry.text,
+            ) for entry in self.diagnosis.items()
+        ]
 
+
 class RadarClient(object):
-    def __init__(self, parent):
+    def __init__(self, parent, authentication_strategy):
         self.parent = parent
+        self.authentication_strategy = authentication_strategy
 
     def radar_for_id(self, problem_id):
         found = self.parent.issues.get(problem_id)
@@ -137,22 +161,32 @@
     top = None
 
     class AuthenticationStrategySystemAccount(object):
-        def __init__(self, _, __, ___, ____):
-            pass
+        def __init__(self, username, __, ___, ____):
+            self._username = username
 
+        def username(self):
+            return self._username
+
     class AuthenticationStrategySPNego(object):
-        pass
+        def username(self):
+            return os.environ.get('RADAR_USERNAME')
 
     class ClientSystemIdentifier(object):
         def __init__(self, name, version):
             pass
 
+    class DiagnosisEntry(object):
+        def __init__(self, text=None, addedAt=None, addedBy=None):
+            self.text = text
+            self.addedAt = addedAt
+            self.addedBy = addedBy
+
     @classmethod
     def transform_user(cls, user):
         return User(
             name=user.name,
             username=sum(bytearray(string_utils.encode(user.email))) % 1000,
-            emails=user.emails,
+            emails=user.emails + [user.email.split('@')[0] + '@APPLECONNECT.APPLE.COM'],
         )
 
     def __init__(self, users=None, issues=None):
@@ -168,7 +202,7 @@
             self.add(issue)
 
         self.AppleDirectoryQuery = AppleDirectoryQuery(self)
-        self.RadarClient = lambda authentication_strategy, client_system_identifier: RadarClient(self)
+        self.RadarClient = lambda authentication_strategy, client_system_identifier: RadarClient(self, authentication_strategy)
 
         from mock import patch
         self.patches.append(patch('webkitbugspy.radar.Tracker.radarclient', new=lambda s=None: self))

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -23,8 +23,9 @@
 import calendar
 import re
 import sys
+import time
 
-from webkitcorepy import Environment
+from webkitcorepy import Environment, decorators
 from webkitbugspy import Issue, Tracker as GenericTracker, User, name as library_name, version as library_version
 
 
@@ -81,8 +82,10 @@
             return user
         if not name or not username or not email:
             found = None
-            if username:
+            if isinstance(username, int):
                 found = self.library.AppleDirectoryQuery.user_entry_for_dsid(int(username))
+            elif username:
+                found = self.library.AppleDirectoryQuery.user_entry_for_attribute_value('uid', '{}@APPLECONNECT.APPLE.COM'.format(username))
             elif email:
                 found = self.library.AppleDirectoryQuery.user_entry_for_attribute_value('mail', email)
             elif name:
@@ -100,6 +103,11 @@
             emails=[email],
         )
 
+    @decorators.Memoize()
+    def me(self):
+        username = self.authentication().username()
+        return self.user(username=username)
+
     def issue(self, id):
         return Issue(id=int(id), tracker=self)
 
@@ -174,3 +182,29 @@
                 refs.add(candidate.link)
 
         return issue
+
+    def add_comment(self, issue, text):
+        if not self.client or not self.library:
+            sys.stderr.write('radarclient inaccessible on this machine\n')
+            return None
+
+        radar = self.client.radar_for_id(issue.id)
+        if not radar:
+            sys.stderr.write("Failed to fetch '{}'\n".format(issue.link))
+            return None
+
+        comment = self.library.DiagnosisEntry()
+        comment.text = text
+        radar.diagnosis.add(comment)
+        radar.commit_changes()
+
+        result = Issue.Comment(
+            user=self.me(),
+            timestamp=int(time.time()),
+            content=comment.text,
+        )
+        if not issue._comments:
+            self.populate(issue, 'comments')
+        issue._comments.append(result)
+
+        return result

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -19,11 +19,11 @@
 # 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 json
+import os
 import unittest
 
 from webkitbugspy import Issue, User, bugzilla, mocks
+from webkitcorepy import mocks as wkmocks
 
 
 class TestBugzilla(unittest.TestCase):
@@ -130,13 +130,38 @@
             self.assertEqual(tracker.issue(3).references, [tracker.issue(2)])
 
     def test_reference_parse(self):
-        with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES) as mock:
+        with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+            BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+            BUGS_EXAMPLE_COM_PASSWORD='password',
+        )):
             tracker = bugzilla.Tracker(self.URL)
-            mock.issues[1]['comments'].append(
-                Issue.Comment(
-                    user=mocks.USERS['Wilma Watcher'],
-                    timestamp=1639539630,
-                    content='Is this related to {}/show_bug.cgi?id=2?'.format(self.URL),
-                ),
+            tracker.issue(1).add_comment('Is this related to {}/show_bug.cgi?id=2?'.format(self.URL))
+            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_me(self):
+        with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+            BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+            BUGS_EXAMPLE_COM_PASSWORD='password',
+        )):
+            self.assertEqual(
+                User.Encoder().default(bugzilla.Tracker(self.URL).me()),
+                dict(name='Tim Contributor', username='[email protected]', emails=['[email protected]']),
             )
-            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_add_comment(self):
+        with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+                BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+                BUGS_EXAMPLE_COM_PASSWORD='password',
+        )):
+            issue = bugzilla.Tracker(self.URL).issue(1)
+            self.assertEqual(len(issue.comments), 2)
+
+            comment = issue.add_comment('Automated comment')
+            self.assertEqual(comment.content, 'Automated comment')
+            self.assertEqual(
+                User.Encoder().default(comment.user),
+                User.Encoder().default(bugzilla.Tracker(self.URL).me()),
+            )
+
+            self.assertEqual(len(issue.comments), 3)
+            self.assertEqual(len(bugzilla.Tracker(self.URL).issue(1).comments), 3)

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -20,10 +20,10 @@
 # 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 json
 import unittest
 
 from webkitbugspy import Issue, User, github, mocks
+from webkitcorepy import mocks as wkmocks
 
 
 class TestGitHub(unittest.TestCase):
@@ -105,15 +105,12 @@
             )
 
     def test_watcher_parse(self):
-        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES) as mock:
+        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+                GITHUB_EXAMPLE_COM_USERNAME='tcontributor',
+                GITHUB_EXAMPLE_COM_TOKEN='token',
+        )):
             tracker = github.Tracker(self.URL)
-            mock.issues[2]['comments'].append(
-                Issue.Comment(
-                    user=mocks.USERS['Tim Contributor'],
-                    timestamp=1639539630,
-                    content='Looks like @ffiler stumbled upon this in #3',
-                ),
-            )
+            tracker.issue(2).add_comment('Looks like @ffiler stumbled upon this in #3')
             self.assertEqual(
                 User.Encoder().default(tracker.issue(2).watchers), [
                     dict(name='Tim Contributor', username='tcontributor', emails=['[email protected]']),
@@ -130,13 +127,38 @@
             self.assertEqual(tracker.issue(3).references, [tracker.issue(2)])
 
     def test_reference_parse(self):
-        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES) as mock:
+        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+            GITHUB_EXAMPLE_COM_USERNAME='wwatcher',
+            GITHUB_EXAMPLE_COM_TOKEN='token',
+        )):
             tracker = github.Tracker(self.URL)
-            mock.issues[1]['comments'].append(
-                Issue.Comment(
-                    user=mocks.USERS['Wilma Watcher'],
-                    timestamp=1639539630,
-                    content='Is this related to #2?',
-                ),
+            tracker.issue(1).add_comment('Is this related to #2?')
+            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_me(self):
+        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+            GITHUB_EXAMPLE_COM_USERNAME='tcontributor',
+            GITHUB_EXAMPLE_COM_TOKEN='token',
+        )):
+            self.assertEqual(
+                User.Encoder().default(github.Tracker(self.URL).me()),
+                dict(name='Tim Contributor', username='tcontributor', emails=['[email protected]']),
             )
-            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_add_comment(self):
+        with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+            GITHUB_EXAMPLE_COM_USERNAME='tcontributor',
+            GITHUB_EXAMPLE_COM_TOKEN='token',
+        )):
+            issue = github.Tracker(self.URL).issue(1)
+            self.assertEqual(len(issue.comments), 2)
+
+            comment = issue.add_comment('Automated comment')
+            self.assertEqual(comment.content, 'Automated comment')
+            self.assertEqual(
+                User.Encoder().default(comment.user),
+                User.Encoder().default(github.Tracker(self.URL).me()),
+            )
+
+            self.assertEqual(len(issue.comments), 3)
+            self.assertEqual(len(github.Tracker(self.URL).issue(1).comments), 3)

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -23,9 +23,10 @@
 import unittest
 
 from webkitbugspy import Issue, User, radar, mocks
+from webkitcorepy import mocks as wkmocks
 
 
-class TestGitHub(unittest.TestCase):
+class TestRadar(unittest.TestCase):
     def test_no_radar(self):
         with mocks.NoRadar():
             tracker = radar.Tracker()
@@ -124,13 +125,29 @@
             self.assertEqual(tracker.issue(3).references, [tracker.issue(2)])
 
     def test_reference_parse(self):
-        with mocks.Radar(issues=mocks.ISSUES) as mock:
+        with wkmocks.Environment(RADAR_USERNAME='wwatcher'), mocks.Radar(issues=mocks.ISSUES) as mock:
             tracker = radar.Tracker()
-            mock.issues[1]['comments'].append(
-                Issue.Comment(
-                    user=mocks.USERS['Wilma Watcher'],
-                    timestamp=1639539630,
-                    content='Is this related to <rdar://2> ?',
-                ),
+            tracker.issue(1).add_comment('Is this related to <rdar://2> ?')
+            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_me(self):
+        with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES):
+            self.assertEqual(
+                User.Encoder().default(radar.Tracker().me()),
+                dict(name='Tim Contributor', username=504, emails=['[email protected]']),
             )
-            self.assertEqual(tracker.issue(1).references, [tracker.issue(2)])
+
+    def test_add_comment(self):
+        with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES):
+            issue = radar.Tracker().issue(1)
+            self.assertEqual(len(issue.comments), 2)
+
+            comment = issue.add_comment('Automated comment')
+            self.assertEqual(comment.content, 'Automated comment')
+            self.assertEqual(
+                User.Encoder().default(comment.user),
+                User.Encoder().default(radar.Tracker().me()),
+            )
+
+            self.assertEqual(len(issue.comments), 3)
+            self.assertEqual(len(radar.Tracker().issue(1).comments), 3)

Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -66,8 +66,15 @@
                 return self.users.get(key)
         return None
 
+    @decorators.Memoize()
+    def me(self):
+        raise NotImplementedError()
+
     def issue(self, id):
         raise NotImplementedError()
 
     def populate(self, issue, member=None):
         raise NotImplementedError()
+
+    def add_comment(self, issue, text):
+        raise NotImplementedError()

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/setup.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitcorepy/setup.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/setup.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -30,7 +30,7 @@
 
 setup(
     name='webkitcorepy',
-    version='0.12.6',
+    version='0.12.7',
     description='Library containing various Python support classes and functions.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -44,7 +44,7 @@
 from webkitcorepy.editor import Editor
 from webkitcorepy.file_lock import FileLock
 
-version = Version(0, 12, 6)
+version = Version(0, 12, 7)
 
 from webkitcorepy.autoinstall import Package, AutoInstall
 if sys.version_info > (3, 0):

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py (288311 => 288312)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py	2022-01-20 19:16:42 UTC (rev 288311)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -27,3 +27,4 @@
 from webkitcorepy.mocks.requests_ import Response, Requests
 from webkitcorepy.mocks.terminal import Terminal
 from webkitcorepy.mocks.file_lock import FileLock
+from webkitcorepy.mocks.environment import Environment

Copied: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/environment.py (from rev 288310, trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py) (0 => 288312)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/environment.py	                        (rev 0)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/environment.py	2022-01-20 19:48:18 UTC (rev 288312)
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2.  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.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 os
+
+from webkitcorepy.mocks import ContextStack
+
+
+class Environment(ContextStack):
+    top = None
+
+    def __init__(self, **kwargs):
+        super(Environment, self).__init__(cls=Environment)
+
+        from mock import patch
+        from webkitcorepy.credentials import _cache
+
+        self.patches.append(patch.dict(os.environ, kwargs))
+        self.patches.append(patch.dict(_cache, dict()))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to