Reland "Update fetch protocol using --protocol-override flag"
This is a reland of commit 6817010e83ab93bb2b3db91f512f26ff356960c9
Additional Changes:
This reland fixes https://crbug.com/1330995 by stopping gclient from accidentally updating the scheme when one is not present.
Original change's description:
> Update fetch protocol using --protocol-override flag
>
> This CL updates gclient sync to use the protocol of the URL specified in the solutions for cloning all the child dependencies of it.
>
> Bug: chrome-operations:170
> Change-Id: I33588059788b677fbae8c3b434100af5c7979a67
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3631600
> Reviewed-by: Joanna Wang <jojwang@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Bug: 1330995
Change-Id: I1447a5e884e41d671d8556c35193f1635f2f6936
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3684112
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
diff --git a/fetch.py b/fetch.py
index 916d64f..0320207 100755
--- a/fetch.py
+++ b/fetch.py
@@ -24,6 +24,7 @@
import argparse
import os
import pipes
+import re
import subprocess
import sys
import textwrap
@@ -34,7 +35,6 @@
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
-DEFAULT_PROTOCOL = 'https'
#################################################
# Checkout class definitions.
@@ -204,7 +204,7 @@
'-p',
'--protocol-override',
type=str,
- default=DEFAULT_PROTOCOL,
+ default=None,
help='Protocol to use to fetch dependencies, defaults to https.')
parser.add_argument('config', type=str,
@@ -259,6 +259,13 @@
assert 'type' in spec
checkout_type = spec['type']
checkout_spec = spec['%s_spec' % checkout_type]
+
+ # Replace https using the protocol specified in --protocol-override
+ if options.protocol_override is not None:
+ for solution in checkout_spec['solutions']:
+ solution['url'] = re.sub(
+ '^([a-z]+):', options.protocol_override + ':', solution['url'])
+
try:
checkout = CheckoutFactory(checkout_type, options, checkout_spec, root)
except KeyError: