Log Message
[reporelaypy] Support credentialed https repositories https://bugs.webkit.org/show_bug.cgi?id=237853 <rdar://90252426>
Reviewed by Ryan Haddad, Dewei Zhu and Stephanie Lewis. * Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version. * Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py: (Checkout.Encoder.default): Pass credentials. (Checkout.clone): Add credentials to local configuration. (Checkout.add_credentials): Add username to .git/config and populate .git-credentials file appropriately. (Checkout.__init__): Re-add credentials. * Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py: (CheckoutUnittest.test_json): * Tools/Scripts/libraries/reporelaypy/setup.py: Bump version. Canonical link: https://commits.webkit.org/248534@main
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (291403 => 291404)
--- trunk/Tools/ChangeLog 2022-03-17 13:02:32 UTC (rev 291403)
+++ trunk/Tools/ChangeLog 2022-03-17 14:27:51 UTC (rev 291404)
@@ -1,3 +1,22 @@
+2022-03-16 Jonathan Bedard <[email protected]>
+
+ [reporelaypy] Support credentialed https repositories
+ https://bugs.webkit.org/show_bug.cgi?id=237853
+ <rdar://90252426>
+
+ Reviewed by Ryan Haddad, Dewei Zhu and Stephanie Lewis.
+
+ * Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version.
+ * Scripts/libraries/reporelaypy/reporelaypy/checkout.py:
+ (Checkout.Encoder.default): Pass credentials.
+ (Checkout.clone): Add credentials to local configuration.
+ (Checkout.add_credentials): Add username to .git/config and populate
+ .git-credentials file appropriately.
+ (Checkout.__init__): Re-add credentials.
+ * Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py:
+ (CheckoutUnittest.test_json):
+ * Scripts/libraries/reporelaypy/setup.py: Bump version.
+
2022-03-17 Nikolas Zimmermann <[email protected]>
Build broken on macOS Monterey 12.3 - PassKitSPI related error
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py (291403 => 291404)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py 2022-03-17 13:02:32 UTC (rev 291403)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py 2022-03-17 14:27:51 UTC (rev 291404)
@@ -44,7 +44,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 4, 1)
+version = Version(0, 4, 2)
import webkitflaskpy
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py (291403 => 291404)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py 2022-03-17 13:02:32 UTC (rev 291403)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/checkout.py 2022-03-17 14:27:51 UTC (rev 291404)
@@ -48,6 +48,7 @@
url=""
sentinal=obj.sentinal,
remotes=obj.remotes,
+ credentials=obj.credentials,
)
if obj.fallback_repository:
result['fallback_url'] = obj.fallback_repository.url
@@ -61,11 +62,12 @@
return cls(**data, primary=False)
@staticmethod
- def clone(url, path, remotes, sentinal_file=None):
+ def clone(url, path, remotes, credentials, sentinal_file=None):
run([local.Git.executable(), 'clone', url, path], cwd=os.path.dirname(path))
run([local.Git.executable(), 'config', 'pull.ff', 'only'], cwd=path)
Checkout.add_remotes(local.Git(path), remotes)
+ Checkout.add_credentials(local.Git(path), credentials)
if sentinal_file:
with open(sentinal_file, 'w') as cloned:
@@ -77,11 +79,35 @@
for name, url in (remotes or {}).items():
run([repository.executable(), 'remote', 'add', name, url], cwd=repository.root_path)
- def __init__(self, path, url="" http_proxy=None, sentinal=True, fallback_url=None, primary=True, remotes=None):
+ @staticmethod
+ def add_credentials(repository, credentials):
+ git_credentials_content = ''
+
+ for url, creds in (credentials or {}).items():
+ username = creds.get('username')
+ password = creds.get('password')
+ if username:
+ run(
+ [repository.executable(), 'config', '--local', 'credential.{}.username'.format(url), username],
+ cwd=repository.root_path,
+ )
+ protocol, host = url.split('://')
+ if username and password and protocol and host:
+ git_credentials_content += '{}://{}:{}@{}\n'.format(protocol, username, password, host)
+
+ if not git_credentials_content:
+ return
+
+ run([repository.executable(), 'config', '--local', 'credential.helper', 'store'], cwd=repository.root_path)
+ with open(os.path.expanduser('~/.git-credentials'), 'w') as f:
+ f.write(git_credentials_content)
+
+ def __init__(self, path, url="" http_proxy=None, sentinal=True, fallback_url=None, primary=True, remotes=None, credentials=None):
self.sentinal = sentinal
self.path = path
self.url = ""
self.remotes = remotes or dict()
+ self.credentials = credentials or dict()
self._repository = None
self._child_process = None
self.fallback_repository = remote.Scm.from_url(fallback_url) if fallback_url else None
@@ -110,6 +136,7 @@
))
if primary:
Checkout.add_remotes(self.repository, remotes)
+ Checkout.add_credentials(self.repository, self.credentials)
return
except FileNotFoundError:
pass
@@ -128,11 +155,11 @@
if self.sentinal:
self._child_process = multiprocessing.Process(
target=self.clone,
- args=(self.url, path, self.remotes, self.sentinal_file),
+ args=(self.url, path, self.remotes, self.credentials, self.sentinal_file),
)
self._child_process.start()
else:
- self.clone(self.url, path, self.remotes)
+ self.clone(self.url, path, self.remotes, self.credentials)
@property
def sentinal_file(self):
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py (291403 => 291404)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py 2022-03-17 13:02:32 UTC (rev 291403)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/checkout_unittest.py 2022-03-17 14:27:51 UTC (rev 291404)
@@ -35,6 +35,41 @@
super(CheckoutUnittest, self).setUp()
os.mkdir(os.path.join(self.path, '.git'))
+ def test_json(self):
+ with mocks.local.Git(self.path) as repo, OutputCapture():
+ checkout = Checkout(
+ path=self.path,
+ url=""
+ credentials={
+ 'https://github.com': dict(
+ username='username',
+ password='password',
+ ),
+ }, sentinal=False,
+ )
+
+ encoded = Checkout.Encoder().default(checkout)
+ self.assertEqual(
+ encoded, dict(
+ path=self.path,
+ url=""
+ remotes={},
+ credentials={
+ 'https://github.com': dict(
+ username='username',
+ password='password',
+ ),
+ }, sentinal=False,
+ ),
+ )
+
+ constructed = Checkout(**encoded)
+ self.assertEqual(checkout.path, constructed.path)
+ self.assertEqual(checkout.url, constructed.url)
+ self.assertEqual(checkout.remotes, constructed.remotes)
+ self.assertEqual(checkout.credentials, constructed.credentials)
+
+
def test_constructor_sentinal(self):
with mocks.local.Git(self.path) as repo, OutputCapture():
with open(os.path.join(os.path.dirname(self.path), 'cloned'), 'w') as sentinal:
Modified: trunk/Tools/Scripts/libraries/reporelaypy/setup.py (291403 => 291404)
--- trunk/Tools/Scripts/libraries/reporelaypy/setup.py 2022-03-17 13:02:32 UTC (rev 291403)
+++ trunk/Tools/Scripts/libraries/reporelaypy/setup.py 2022-03-17 14:27:51 UTC (rev 291404)
@@ -30,7 +30,7 @@
setup(
name='reporelaypy',
- version='0.4.1',
+ version='0.4.2',
description='Library for visualizing, processing and storing test results.',
long_description=readme(),
classifiers=[
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
