Эх сурвалжийг харах

[git_auth] Add guard against bad URLs

In particular, when we enable new auth by default, one of the tests
that uses gclient to clone a local directory fails.

Bug: 404613530
Change-Id: I1bd41da2a3aba6f92cc3d5d9c75ab4d8fc293f22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6426441
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Allen Li 4 сар өмнө
parent
commit
321b0e6b99
1 өөрчлөгдсөн 6 нэмэгдсэн , 0 устгасан
  1. 6 0
      git_auth.py

+ 6 - 0
git_auth.py

@@ -319,8 +319,14 @@ def Configure(cwd: str, cl: git_cl.Changelist) -> None:
 def ConfigureGlobal(cwd: str, remote_url: str) -> None:
     """Configure global/user Git authentication."""
     logging.debug('Configuring global Git authentication for %s', remote_url)
+    # Checks to ensure this doesn't error when called with "bad" URLs.
+    #
+    # Don't try to configure auth for local files.
     if remote_url.startswith('file://'):
         return
+    # Skip for local files that aren't even URIs.
+    if '://' not in remote_url:
+        return
     ConfigChanger.new_for_remote(cwd, remote_url).apply_global(cwd)