Bläddra i källkod

Add --protocol-override to fetch.py

This CL adds a non-functional `--protocol` flag to fetch.py. This will be used in the follow-up CL to update fetching protocol.

Bug: 1322156
Change-Id: I7eeebb9993face20bb671d6942ee23fd04802d8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3609453
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Aravind Vasudevan 3 år sedan
förälder
incheckning
fb8cf9cc78
2 ändrade filer med 23 tillägg och 1 borttagningar
  1. 7 0
      fetch.py
  2. 16 1
      tests/fetch_test.py

+ 7 - 0
fetch.py

@@ -34,6 +34,7 @@ from distutils import spawn
 
 
 
 
 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
+DEFAULT_PROTOCOL = 'https'
 
 
 #################################################
 #################################################
 # Checkout class definitions.
 # Checkout class definitions.
@@ -199,6 +200,12 @@ def handle_args(argv):
     help='Perform shallow clones, don\'t fetch the full git history.')
     help='Perform shallow clones, don\'t fetch the full git history.')
   parser.add_argument('--force', action='store_true', default=False,
   parser.add_argument('--force', action='store_true', default=False,
     help='(dangerous) Don\'t look for existing .gclient file.')
     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,
   parser.add_argument('config', type=str,
     help="Project to fetch, e.g. chromium.")
     help="Project to fetch, e.g. chromium.")

+ 16 - 1
tests/fetch_test.py

@@ -54,11 +54,12 @@ class TestUtilityFunctions(unittest.TestCase):
       no_history=False,
       no_history=False,
       force=False,
       force=False,
       config='foo',
       config='foo',
+      protocol_override='https',
       props=[]), response)
       props=[]), response)
 
 
     response = fetch.handle_args([
     response = fetch.handle_args([
         'filename', '-n', '--dry-run', '--nohooks', '--no-history', '--force',
         '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(
     self.assertEqual(argparse.Namespace(
       dry_run=True,
       dry_run=True,
@@ -66,6 +67,20 @@ class TestUtilityFunctions(unittest.TestCase):
       no_history=True,
       no_history=True,
       force=True,
       force=True,
       config='foo',
       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)
       props=['--some-param=1', '--bar=2']), response)
 
 
   @mock.patch('os.path.exists', return_value=False)
   @mock.patch('os.path.exists', return_value=False)