[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>
This commit is contained in:
Allen Li
2025-04-02 15:45:19 -07:00
committed by LUCI CQ
parent eae511073a
commit 321b0e6b99

View File

@@ -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)