diff --git a/fetch.py b/fetch.py index 0320207cf..916d64f97 100755 --- a/fetch.py +++ b/fetch.py @@ -24,7 +24,6 @@ import json import argparse import os import pipes -import re import subprocess import sys import textwrap @@ -35,6 +34,7 @@ from distutils import spawn SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) +DEFAULT_PROTOCOL = 'https' ################################################# # Checkout class definitions. @@ -204,7 +204,7 @@ def handle_args(argv): '-p', '--protocol-override', type=str, - default=None, + default=DEFAULT_PROTOCOL, help='Protocol to use to fetch dependencies, defaults to https.') parser.add_argument('config', type=str, @@ -259,13 +259,6 @@ def run(options, spec, root): 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: diff --git a/gclient.py b/gclient.py index 681e9322f..c2a6fb349 100755 --- a/gclient.py +++ b/gclient.py @@ -396,8 +396,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): def __init__(self, parent, name, url, managed, custom_deps, custom_vars, custom_hooks, deps_file, should_process, - should_recurse, relative, condition, protocol='https', - print_outbuf=False): + should_recurse, relative, condition, print_outbuf=False): gclient_utils.WorkItem.__init__(self, name) DependencySettings.__init__( self, parent, url, managed, custom_deps, custom_vars, @@ -463,8 +462,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): # dependency self.print_outbuf = print_outbuf - self.protocol = protocol - if not self.name and self.parent: raise gclient_utils.Error('Dependency without name') @@ -693,8 +690,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): GitDependency( parent=self, name=name, - # Update URL with parent dep's protocol - url=GitDependency.updateProtocol(url, self.protocol), + url=url, managed=True, custom_deps=None, custom_vars=self.custom_vars, @@ -703,8 +699,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): should_process=should_process, should_recurse=name in self.recursedeps, relative=use_relative_paths, - condition=condition, - protocol=self.protocol)) + condition=condition)) deps_to_add.sort(key=lambda x: x.name) return deps_to_add @@ -1347,16 +1342,6 @@ def _detect_host_os(): class GitDependency(Dependency): """A Dependency object that represents a single git checkout.""" - @staticmethod - def updateProtocol(url, protocol): - """Updates given URL's protocol""" - # only works on urls, skips local paths - if not url or not protocol or not re.match('([a-z]+)://', url) or \ - re.match('file://', url): - return url - - return re.sub('^([a-z]+):', protocol + ':', url) - #override def GetScmName(self): """Always 'git'.""" @@ -1538,9 +1523,7 @@ it or fix the checkout. should_recurse=True, relative=None, condition=None, - print_outbuf=True, - # Pass parent URL protocol down the tree for child deps to use. - protocol=s['url'].split('://')[0] if s['url'] else None)) + print_outbuf=True)) except KeyError: raise gclient_utils.Error('Invalid .gclient file. Solution is ' 'incomplete: %s' % s) @@ -1769,8 +1752,7 @@ it or fix the checkout. GitDependency( parent=self, name=entry, - # Update URL with parent dep's protocol - url=GitDependency.updateProtocol(prev_url, self.protocol), + url=prev_url, managed=False, custom_deps={}, custom_vars={}, @@ -1779,8 +1761,7 @@ it or fix the checkout. should_process=True, should_recurse=False, relative=None, - condition=None, - protocol=self.protocol)) + condition=None)) if modified_files and self._options.delete_unversioned_trees: print('\nWARNING: \'%s\' is no longer part of this client.\n' 'Despite running \'gclient sync -D\' no action was taken ' diff --git a/tests/fetch_test.py b/tests/fetch_test.py index 95d5aebcd..5b427aac6 100755 --- a/tests/fetch_test.py +++ b/tests/fetch_test.py @@ -54,7 +54,7 @@ class TestUtilityFunctions(unittest.TestCase): no_history=False, force=False, config='foo', - protocol_override=None, + protocol_override='https', props=[]), response) response = fetch.handle_args([ diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 01ec1f32f..c123234dd 100755 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -236,7 +236,6 @@ class GclientTest(trial_dir.TestCase): should_recurse=False, relative=False, condition=None, - protocol='https', print_outbuf=True) self.assertEqual('proto://host/path@revision', d.url) @@ -259,7 +258,6 @@ class GclientTest(trial_dir.TestCase): should_recurse=True, relative=False, condition=None, - protocol='https', print_outbuf=True), gclient.Dependency( parent=obj, @@ -274,7 +272,6 @@ class GclientTest(trial_dir.TestCase): should_recurse=False, relative=False, condition=None, - protocol='https', print_outbuf=True), ], []) @@ -293,7 +290,6 @@ class GclientTest(trial_dir.TestCase): should_recurse=False, relative=False, condition=None, - protocol='https', print_outbuf=True), ], []) @@ -1312,7 +1308,6 @@ class GclientTest(trial_dir.TestCase): should_recurse=True, relative=False, condition=None, - protocol='https', print_outbuf=True), ], [])