Title: [291138] trunk
Revision
291138
Author
[email protected]
Date
2022-03-10 16:38:44 -0800 (Thu, 10 Mar 2022)

Log Message

[git-webkit] Support multiple metadata locations
https://bugs.webkit.org/show_bug.cgi?id=237395
<rdar://problem/89715863>

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git): Rename PROJECT_CONFIG_PATH to GIT_CONFIG_EXTENSION.
(Git.config): Use dynamic context.metadata instead of constant.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py:
(Scm.__init__): Use self.metadata instead of constant.
(Scm.metadata): Support multiple locations for this directory.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py:
(Setup.git): Use dynamic repository.metadata instead of constant.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
* metadata/git_config_extension: Renamed from metadata/project_config.
* metadata/project_config: Renamed to metadata/git_config_extension.

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

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/ChangeLog (291137 => 291138)


--- trunk/ChangeLog	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/ChangeLog	2022-03-11 00:38:44 UTC (rev 291138)
@@ -1,3 +1,14 @@
+2022-03-08  Jonathan Bedard  <[email protected]>
+
+        [git-webkit] Support multiple metadata locations
+        https://bugs.webkit.org/show_bug.cgi?id=237395
+        <rdar://problem/89715863>
+
+        Reviewed by Dewei Zhu.
+
+        * metadata/git_config_extension: Renamed from metadata/project_config.
+        * metadata/project_config: Renamed to metadata/git_config_extension.
+
 2022-03-10  Elliott Williams  <[email protected]>
 
         [XCBuild] Fix GeneratedSources dependency validation errors

Modified: trunk/Tools/ChangeLog (291137 => 291138)


--- trunk/Tools/ChangeLog	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/ChangeLog	2022-03-11 00:38:44 UTC (rev 291138)
@@ -1,3 +1,23 @@
+2022-03-10  Jonathan Bedard  <[email protected]>
+
+        [git-webkit] Support multiple metadata locations
+        https://bugs.webkit.org/show_bug.cgi?id=237395
+        <rdar://problem/89715863>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git): Rename PROJECT_CONFIG_PATH to GIT_CONFIG_EXTENSION.
+        (Git.config): Use dynamic context.metadata instead of constant.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py:
+        (Scm.__init__): Use self.metadata instead of constant.
+        (Scm.metadata): Support multiple locations for this directory.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py:
+        (Setup.git): Use dynamic repository.metadata instead of constant.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
+
 2022-03-10  Wenson Hsieh  <[email protected]>
 
         [iOS] Add support for -[UITextInput addTextAlternatives:] on WKContentView

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (291137 => 291138)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='4.3.13',
+    version='4.4.0',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (291137 => 291138)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(4, 3, 13)
+version = Version(4, 4, 0)
 
 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 (291137 => 291138)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -302,7 +302,7 @@
     HTTP_REMOTE = re.compile(r'(?P<protocol>https?)://(?P<host>[^\/]+)/(?P<path>.+).git')
     REMOTE_BRANCH = re.compile(r'remotes\/(?P<remote>[^\/]+)\/(?P<branch>.+)')
     USER_REMOTE = re.compile(r'(?P<username>[^:/]+):(?P<branch>.+)')
-    PROJECT_CONFIG_PATH = os.path.join(Scm.METADATA, 'project_config')
+    GIT_CONFIG_EXTENSION = 'git_config_extension'
     PROJECT_CONFIG_OPTIONS = {
         'pull.rebase': ['true', 'false'],
         'webkitscmpy.pull-request': ['overwrite', 'append'],
@@ -337,9 +337,9 @@
             kwargs['cwd'] = context.root_path
             if location == 'project':
                 # Without a project config, use the library defaults
-                if not os.path.isfile(os.path.join(context.root_path, context.PROJECT_CONFIG_PATH)):
+                if not context.metadata or not os.path.isfile(os.path.join(context.metadata, context.GIT_CONFIG_EXTENSION)):
                     return {key: values[0] for key, values in context.PROJECT_CONFIG_OPTIONS.items()}
-                args += ['--file', context.PROJECT_CONFIG_PATH]
+                args += ['--file', os.path.join(context.metadata, context.GIT_CONFIG_EXTENSION)]
 
         command = run(args, **kwargs)
         if command.returncode:

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py (291137 => 291138)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/scm.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
+# Copyright (C) 2020-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
@@ -26,6 +26,7 @@
 import six
 
 from webkitbugspy import Tracker, bugzilla, github, radar
+from webkitcorepy import decorators
 from webkitscmpy import ScmBase, Contributor
 
 
@@ -34,7 +35,6 @@
     # the following idioms seem common enough to be shared.
     DEV_BRANCHES = re.compile(r'.*[(eng)(dev)(bug)]/.+')
     PROD_BRANCHES = re.compile(r'\S+-[\d+\.]+-branch')
-    METADATA = 'metadata'
 
     @classmethod
     def executable(cls, program):
@@ -61,9 +61,9 @@
         self.path = path
 
         root_path = self.root_path
-        if not contributors and root_path:
+        if not contributors and self.metadata:
             for candidate in [
-                os.path.join(root_path, self.METADATA, 'contributors.json'),
+                os.path.join(self.metadata, 'contributors.json'),
             ]:
                 if not os.path.isfile(candidate):
                     continue
@@ -73,8 +73,8 @@
         super(Scm, self).__init__(dev_branches=dev_branches, prod_branches=prod_branches, contributors=contributors, id=id)
 
         trackers = []
-        if root_path:
-            path = os.path.join(root_path, self.METADATA, 'trackers.json')
+        if self.metadata:
+            path = os.path.join(self.metadata, 'trackers.json')
             if os.path.isfile(path):
                 with open(path, 'r') as file:
                     trackers = Tracker.from_json(json.load(file))
@@ -92,6 +92,17 @@
             Tracker.register(tracker)
 
     @property
+    @decorators.Memoize()
+    def metadata(self):
+        if not self.root_path:
+            return None
+        for name in ('metadata', '.repo-metadata'):
+            candidate = os.path.join(self.root_path, name)
+            if os.path.isdir(candidate):
+                return candidate
+        return None
+
+    @property
     def root_path(self):
         raise NotImplementedError()
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py (291137 => 291138)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -118,10 +118,10 @@
         else:
             log.info("Set git user name to '{}' for this repository".format(name))
 
-        if os.path.isfile(os.path.join(repository.path, local.Git.PROJECT_CONFIG_PATH)):
+        if repository.metadata and os.path.isfile(os.path.join(repository.metadata, local.Git.GIT_CONFIG_EXTENSION)):
             log.info('Adding project git config to repository config...')
             result += run(
-                [local.Git.executable(), 'config', 'include.path', os.path.join('..', local.Git.PROJECT_CONFIG_PATH)],
+                [local.Git.executable(), 'config', 'include.path', os.path.join('..', os.path.basename(repository.metadata), local.Git.GIT_CONFIG_EXTENSION)],
                 capture_output=True, cwd=repository.root_path,
             ).returncode
             log.info('Added project git config to repository config!')

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


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py	2022-03-11 00:38:44 UTC (rev 291138)
@@ -411,7 +411,7 @@
 
     def test_project_config(self):
         with mocks.local.Git(self.path, git_svn=True):
-            project_config = os.path.join(self.path, local.Git.PROJECT_CONFIG_PATH)
+            project_config = os.path.join(self.path, 'metadata', local.Git.GIT_CONFIG_EXTENSION)
             os.mkdir(os.path.dirname(project_config))
             with open(project_config, 'w') as f:
                 f.write('[webkitscmpy]\n')

Copied: trunk/metadata/git_config_extension (from rev 291137, trunk/metadata/project_config) (0 => 291138)


--- trunk/metadata/git_config_extension	                        (rev 0)
+++ trunk/metadata/git_config_extension	2022-03-11 00:38:44 UTC (rev 291138)
@@ -0,0 +1,6 @@
+[pull]
+        rebase = true
+[webkitscmpy]
+        pull-request = append
+        history = disabled
+        update-fork = true

Deleted: trunk/metadata/project_config (291137 => 291138)


--- trunk/metadata/project_config	2022-03-11 00:28:03 UTC (rev 291137)
+++ trunk/metadata/project_config	2022-03-11 00:38:44 UTC (rev 291138)
@@ -1,6 +0,0 @@
-[pull]
-        rebase = true
-[webkitscmpy]
-        pull-request = append
-        history = disabled
-        update-fork = true
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to