Title: [291772] trunk/Tools
Revision
291772
Author
[email protected]
Date
2022-03-23 16:07:41 -0700 (Wed, 23 Mar 2022)

Log Message

[commits.webkit.org] Sync tags
https://bugs.webkit.org/show_bug.cgi?id=238144
<rdar://problem/90594915>

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version.
* Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py:
(Checkout): Make 'origin' a global variable.
(Checkout.__init__): Ditto.
(Checkout.is_updated): Ditto.
(Checkout.push_update): Support pushing a tag.
(Checkout.fetch): Fetch a specific remote.
(Checkout.update_for): Make 'origin' a global variable.
(Checkout.update_all): Add tag syncing.
* Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py:
(HookProcessor):
(HookProcessor.process_worker_hook): Update tags as well as branches.
* Tools/Scripts/libraries/reporelaypy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/setup.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.tags): List tags for remote.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py:
(Svn.tags): Remove @property tag.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
(Git.__init__): List tags for remote.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py:
(BitBucket.tags): Remove @property tag.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
(GitHub.tags): Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/svn.py:
(Svn.tags): Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/scm_base.py:
(ScmBase.tags): Ditto.
(ScmBase.find): tags is a function instead of a property.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
(TestGit.test_tags):
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py:
(TestLocalSvn.test_tags):
(TestRemoteSvn.test_tags):

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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (291771 => 291772)


--- trunk/Tools/ChangeLog	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/ChangeLog	2022-03-23 23:07:41 UTC (rev 291772)
@@ -1,3 +1,47 @@
+2022-03-22  Jonathan Bedard  <[email protected]>
+
+        [commits.webkit.org] Sync tags
+        https://bugs.webkit.org/show_bug.cgi?id=238144
+        <rdar://problem/90594915>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version.
+        * Scripts/libraries/reporelaypy/reporelaypy/checkout.py:
+        (Checkout): Make 'origin' a global variable.
+        (Checkout.__init__): Ditto.
+        (Checkout.is_updated): Ditto.
+        (Checkout.push_update): Support pushing a tag.
+        (Checkout.fetch): Fetch a specific remote.
+        (Checkout.update_for): Make 'origin' a global variable.
+        (Checkout.update_all): Add tag syncing.
+        * Scripts/libraries/reporelaypy/reporelaypy/hooks.py:
+        (HookProcessor):
+        (HookProcessor.process_worker_hook): Update tags as well as branches.
+        * Scripts/libraries/reporelaypy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/setup.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git.tags): List tags for remote.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py:
+        (Svn.tags): Remove @property tag.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
+        (Git.__init__): List tags for remote. 
+        * Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py:
+        (BitBucket.tags): Remove @property tag.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
+        (GitHub.tags): Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/remote/svn.py:
+        (Svn.tags): Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/scm_base.py:
+        (ScmBase.tags): Ditto.
+        (ScmBase.find): tags is a function instead of a property.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+        (TestGit.test_tags):
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py:
+        (TestLocalSvn.test_tags):
+        (TestRemoteSvn.test_tags):
+
 2022-03-23  Jon Lee  <[email protected]>
 
         Turn DOM in GPU Process on by default on iOS layout tests

Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -44,7 +44,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(0, 4, 2)
+version = Version(0, 5, 0)
 
 import webkitflaskpy
 

Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -31,6 +31,8 @@
 
 
 class Checkout(object):
+    REMOTE = 'origin'
+
     class Exception(RuntimeError):
         pass
 
@@ -129,10 +131,10 @@
         try:
             if self.repository:
                 if not self.url:
-                    self.url = ""
-                if self.url and self.repository.url(name='origin') != self.url:
+                    self.url = ""
+                if self.url and self.repository.url(name=self.REMOTE) != self.url:
                     sys.stderr.write("Specified '{}' as the URL, but the specified path is from '{}'\n".format(
-                        self.url, self.repository.url(name='origin'),
+                        self.url, self.repository.url(name=self.REMOTE),
                     ))
                 if primary:
                     Checkout.add_remotes(self.repository, remotes)
@@ -177,7 +179,7 @@
             return self._repository
         return None
 
-    def is_updated(self, branch, remote='origin'):
+    def is_updated(self, branch, remote=REMOTE):
         if not self.repository:
             sys.stderr.write('Cannot query checkout, clone still pending...\n')
             return None
@@ -202,10 +204,16 @@
                 return ref == line.split()[0]
         return False
 
-    def push_update(self, branch=None, remote=None, track=False):
-        if not remote or remote in ('origin', 'fork'):
+    def push_update(self, branch=None, tag=None, remote=None, track=False):
+        if not remote or remote in (self.REMOTE, 'fork'):
             return False
 
+        if tag:
+            return not run(
+                [self.repository.executable(), 'push', remote, tag],
+                cwd=self.repository.root_path,
+            ).returncode
+
         branch = branch or self.repository.default_branch
         if not track and self.is_updated(branch, remote=remote):
             return False
@@ -215,7 +223,13 @@
             cwd=self.repository.root_path,
         ).returncode
 
-    def update_for(self, branch=None, remote='origin', track=False):
+    def fetch(self, remote=REMOTE):
+        return not run(
+            [self.repository.executable(), 'fetch', remote],
+            cwd=self.repository.root_path,
+        ).returncode
+
+    def update_for(self, branch=None, remote=REMOTE, track=False):
         if not self.repository:
             sys.stderr.write("Cannot update '{}', clone still pending...\n".format(branch))
             return False
@@ -244,7 +258,7 @@
         self.repository.cache.populate(branch=branch)
         return True
 
-    def update_all(self, remote='origin'):
+    def update_all(self, remote=REMOTE):
         if not self.repository:
             sys.stderr.write("Cannot update checkout, clone still pending...\n")
             return None
@@ -253,6 +267,7 @@
         self.repository.cache.populate(branch=self.repository.default_branch)
 
         # First, update all branches we're already tracking
+        print('Updating branches...')
         all_branches = set(self.repository.branches_for(remote=remote))
         for branch in self.repository.branches_for(remote=False):
             if branch in all_branches:
@@ -261,6 +276,7 @@
             [self.push_update(branch=branch, remote=remote) for remote in self.remotes.keys()]
 
         # Then, track all untracked branches
+        print('Tracking new branches...')
         for branch in all_branches:
             run(
                 [self.repository.executable(), 'branch', '--track', branch, 'remotes/{}/{}'.format(remote, branch)],
@@ -268,3 +284,15 @@
             )
             [self.push_update(branch=branch, remote=remote) for remote in self.remotes.keys()]
             self.repository.cache.populate(branch=branch)
+
+        # Sync all tags
+        print('Syncing tags...')
+        origin_tags = set(self.repository.tags(remote=remote))
+        for target_remote in self.remotes.keys():
+            print('Syncing tags for {}...'.format(target_remote))
+            if target_remote == remote:
+                continue
+            remote_tags = set(self.repository.tags(remote=target_remote))
+            for tag in origin_tags - remote_tags:
+                print(f'    {tag}')
+                self.push_update(tag=tag, remote=target_remote)

Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -37,6 +37,8 @@
     INBOUND_KEY = 'inbound-hooks'
     WORKER_HOOKS = 'worker-hooks'
     TYPES = ('pull_request', 'push')
+    BRANCH_PREFIX = 'refs/heads/'
+    TAG_PREFIX = 'refs/tags/'
 
     @classmethod
     def is_valid(cls, type, data):
@@ -68,10 +70,16 @@
         branch = data.get('ref')
         if type == 'push' and branch:
             try:
-                if branch.startswith('refs/heads/'):
-                    branch = branch[len('refs/heads/'):]
-                self.checkout.update_for(branch, track=True)
-                [self.checkout.push_update(branch=branch, remote=remote, track=True) for remote in self.checkout.remotes.keys()]
+                if branch.startswith(self.BRANCH_PREFIX):
+                    branch = branch[len(self.BRANCH_PREFIX):]
+                    self.checkout.update_for(branch, track=True)
+                    [self.checkout.push_update(branch=branch, remote=remote, track=True) for remote in self.checkout.remotes.keys()]
+
+                if branch.startswith(self.TAG_PREFIX):
+                    tag = branch[len(self.TAG_PREFIX):]
+                    self.checkout.fetch()
+                    [self.checkout.push_update(tag=tag, remote=remote) for remote in self.checkout.remotes.keys()]
+
             except BaseException as e:
                 sys.stderr.write('{}\n'.format(e))
 

Modified: trunk/Tools/Scripts/libraries/reporelaypy/setup.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/reporelaypy/setup.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/reporelaypy/setup.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -30,7 +30,7 @@
 
 setup(
     name='reporelaypy',
-    version='0.4.2',
+    version='0.5.0',
     description='Library for visualizing, processing and storing test results.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='4.4.2',
+    version='4.4.3',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(4, 4, 2)
+version = Version(4, 4, 3)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('jinja2', Version(2, 11, 3)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -452,12 +452,22 @@
     def branches(self):
         return self.branches_for()
 
-    @property
-    def tags(self):
-        tags = run([self.executable(), 'tag'], cwd=self.root_path, capture_output=True, encoding='utf-8')
+    def tags(self, remote=None):
+        if not remote:
+            tags = run([self.executable(), 'tag'], cwd=self.root_path, capture_output=True, encoding='utf-8')
+            if tags.returncode:
+                raise self.Exception('Failed to retrieve tag list for {}'.format(self.root_path))
+            return tags.stdout.splitlines()
+
+        tags = run([self.executable(), 'ls-remote', '--tags', remote], cwd=self.root_path, capture_output=True, encoding='utf-8')
         if tags.returncode:
-            raise self.Exception('Failed to retrieve tag list for {}'.format(self.root_path))
-        return tags.stdout.splitlines()
+            raise self.Exception('Failed to retrieve tag list for {} in {}'.format(remote, self.root_path))
+        result = []
+        for line in tags.stdout.splitlines():
+            if line.endswith('^{}'):
+                continue
+            result.append('/'.join(line.split('/')[2:]))
+        return result
 
     def url(self, name=None, cached=None):
         return self.config(cached=cached).get('remote.{}.url'.format(name or 'origin'))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/svn.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -277,7 +277,6 @@
     def branches(self):
         return ['trunk'] + self.list('branches')
 
-    @property
     def tags(self):
         return self.list('tags')
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -233,6 +233,15 @@
                     stdout='\n'.join(sorted(self.tags.keys())) + '\n',
                 ),
             ), mocks.Subprocess.Route(
+                self.executable, 'ls-remote', '--tags', re.compile(r'.+'),
+                cwd=self.path,
+                generator=lambda *args, **kwargs: mocks.ProcessCompletion(
+                    returncode=0,
+                    stdout='\n'.join([
+                        '{hash}\trefs/tags/{tag}\n{hash}\trefs/tags/{tag}^{{}}'.format(hash=commit.hash, tag=tag) for tag, commit in sorted(self.tags.items())
+                    ]) + '\n',
+                ),
+            ), mocks.Subprocess.Route(
                 self.executable, 'rev-parse', '--abbrev-ref', 'origin/HEAD',
                 cwd=self.path,
                 generator=lambda *args, **kwargs: mocks.ProcessCompletion(

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -366,7 +366,6 @@
             return [self.default_branch]
         return sorted([details.get('displayId') for details in response if details.get('displayId')])
 
-    @property
     def tags(self):
         response = self.request('tags')
         if not response:

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


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -397,7 +397,6 @@
             return [self.default_branch]
         return sorted([details.get('name') for details in response if details.get('name')])
 
-    @property
     def tags(self):
         response = self.request('tags')
         if not response:

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/svn.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/svn.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/svn.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -200,7 +200,6 @@
     def branches(self):
         return [self.default_branch] + self.list('branches')
 
-    @property
     def tags(self):
         return self.list('tags')
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/scm_base.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/scm_base.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/scm_base.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -76,7 +76,6 @@
     def branches(self):
         raise NotImplementedError()
 
-    @property
     def tags(self):
         raise NotImplementedError()
 
@@ -155,7 +154,7 @@
         elif argument in self.branches:
             result = self.commit(branch=argument, include_log=include_log, include_identifier=include_identifier)
 
-        elif argument in self.tags:
+        elif argument in self.tags():
             result = self.commit(tag=argument, include_log=include_log, include_identifier=include_identifier)
 
         else:

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -88,10 +88,15 @@
             mock.tags['tag-2'] = mock.commits['branch-b'][-1]
 
             self.assertEqual(
-                local.Git(self.path).tags,
+                local.Git(self.path).tags(),
                 ['tag-1', 'tag-2'],
             )
 
+            self.assertEqual(
+                local.Git(self.path).tags(remote='origin'),
+                ['tag-1', 'tag-2'],
+            )
+
     def test_default_branch(self):
         with mocks.local.Git(self.path):
             self.assertEqual(local.Git(self.path).default_branch, 'main')
@@ -526,7 +531,7 @@
             mock.tags['tag-2'] = mock.commits['branch-b'][-1]
 
             self.assertEqual(
-                remote.GitHub(self.remote).tags,
+                remote.GitHub(self.remote).tags(),
                 ['tag-1', 'tag-2'],
             )
 
@@ -687,7 +692,7 @@
             mock.tags['tag-2'] = mock.commits['branch-b'][-1]
 
             self.assertEqual(
-                remote.BitBucket(self.remote).tags,
+                remote.BitBucket(self.remote).tags(),
                 ['tag-1', 'tag-2'],
             )
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py (291771 => 291772)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py	2022-03-23 22:50:35 UTC (rev 291771)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/svn_unittest.py	2022-03-23 23:07:41 UTC (rev 291772)
@@ -68,7 +68,7 @@
     def test_tags(self):
         with mocks.local.Svn(self.path):
             self.assertEqual(
-                local.Svn(self.path).tags,
+                local.Svn(self.path).tags(),
                 ['tag-1', 'tag-2'],
             )
 
@@ -283,7 +283,7 @@
     def test_tags(self):
         with mocks.remote.Svn():
             self.assertEqual(
-                remote.Svn(self.remote).tags,
+                remote.Svn(self.remote).tags(),
                 ['tag-1', 'tag-2'],
             )
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to