From 810598d1f3725bd5e4b833a2135e4534812718e1 Mon Sep 17 00:00:00 2001 From: Aravind Vasudevan Date: Mon, 13 Jun 2022 21:23:47 +0000 Subject: [PATCH] Add protocol_override entry to .gclient The meta quest browser has an issue with the initial design where the all the dependencies within the same tree are overridden with the solution URL's scheme. This fix updates fetch to add a .gclient entry instead of implicitly overriding the URL's scheme. Bug: 1336027 Change-Id: Iabe5b9017f6eb9e682a0c721f43dd5f347ffcbfb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3703942 Reviewed-by: Josip Sokcevic Commit-Queue: Aravind Vasudevan --- fetch.py | 5 ++--- gclient.py | 20 +++++++------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/fetch.py b/fetch.py index 522639fed2..ba54cc8c0d 100755 --- a/fetch.py +++ b/fetch.py @@ -265,11 +265,10 @@ def run(options, spec, root): os.getcwd().startswith('/google/src/cloud'): options.protocol_override = 'sso' - # Replace https using the protocol specified in --protocol-override + # Update solutions with protocol_override field if options.protocol_override is not None: for solution in checkout_spec['solutions']: - solution['url'] = re.sub( - '^([a-z]+):', options.protocol_override + ':', solution['url']) + solution['protocol_override'] = options.protocol_override try: checkout = CheckoutFactory(checkout_type, options, checkout_spec, root) diff --git a/gclient.py b/gclient.py index bc5cd0953e..812cfbd232 100755 --- a/gclient.py +++ b/gclient.py @@ -693,7 +693,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): GitDependency( parent=self, name=name, - # Update URL with parent dep's protocol + # Update URL with scheme in protocol_override url=GitDependency.updateProtocol(url, self.protocol), managed=True, custom_deps=None, @@ -1446,14 +1446,6 @@ solutions = %(solution_list)s self._cipd_root = None self.config_content = None - @staticmethod - def _getScheme(url): - """Returns the scheme part of the given URL""" - if not url or not re.match('^([a-z]+)://', url): - return None - - return url.split('://')[0] - def _CheckConfig(self): """Verify that the config matches the state of the existing checked-out solutions.""" @@ -1536,7 +1528,9 @@ it or fix the checkout. deps_to_add.append(GitDependency( parent=self, name=s['name'], - url=s['url'], + # Update URL with scheme in protocol_override + url=GitDependency.updateProtocol( + s['url'], s.get('protocol_override', None)), managed=s.get('managed', True), custom_deps=s.get('custom_deps', {}), custom_vars=s.get('custom_vars', {}), @@ -1547,8 +1541,8 @@ it or fix the checkout. relative=None, condition=None, print_outbuf=True, - # Pass parent URL protocol down the tree for child deps to use. - protocol=GClient._getScheme(s['url']))) + # Pass protocol_override down the tree for child deps to use. + protocol=s.get('protocol_override', None))) except KeyError: raise gclient_utils.Error('Invalid .gclient file. Solution is ' 'incomplete: %s' % s) @@ -1777,7 +1771,7 @@ it or fix the checkout. GitDependency( parent=self, name=entry, - # Update URL with parent dep's protocol + # Update URL with scheme in protocol_override url=GitDependency.updateProtocol(prev_url, self.protocol), managed=False, custom_deps={},