diff --git a/fetch.py b/fetch.py index 45e34a138a..916d64f971 100755 --- a/fetch.py +++ b/fetch.py @@ -34,6 +34,7 @@ from distutils import spawn SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) +DEFAULT_PROTOCOL = 'https' ################################################# # Checkout class definitions. @@ -199,6 +200,12 @@ def handle_args(argv): help='Perform shallow clones, don\'t fetch the full git history.') parser.add_argument('--force', action='store_true', default=False, help='(dangerous) Don\'t look for existing .gclient file.') + parser.add_argument( + '-p', + '--protocol-override', + type=str, + default=DEFAULT_PROTOCOL, + help='Protocol to use to fetch dependencies, defaults to https.') parser.add_argument('config', type=str, help="Project to fetch, e.g. chromium.") diff --git a/tests/fetch_test.py b/tests/fetch_test.py index 74ba06cd40..5b427aac68 100755 --- a/tests/fetch_test.py +++ b/tests/fetch_test.py @@ -54,11 +54,12 @@ class TestUtilityFunctions(unittest.TestCase): no_history=False, force=False, config='foo', + protocol_override='https', props=[]), response) response = fetch.handle_args([ 'filename', '-n', '--dry-run', '--nohooks', '--no-history', '--force', - 'foo', '--some-param=1', '--bar=2' + '--protocol-override', 'sso', 'foo', '--some-param=1', '--bar=2' ]) self.assertEqual(argparse.Namespace( dry_run=True, @@ -66,6 +67,20 @@ class TestUtilityFunctions(unittest.TestCase): no_history=True, force=True, config='foo', + protocol_override='sso', + props=['--some-param=1', '--bar=2']), response) + + response = fetch.handle_args([ + 'filename', '-n', '--dry-run', '--nohooks', '--no-history', '--force', + '-p', 'sso', 'foo', '--some-param=1', '--bar=2' + ]) + self.assertEqual(argparse.Namespace( + dry_run=True, + nohooks=True, + no_history=True, + force=True, + config='foo', + protocol_override='sso', props=['--some-param=1', '--bar=2']), response) @mock.patch('os.path.exists', return_value=False)