From 06029eb98c920d658515925dd47aa81c85bf259a Mon Sep 17 00:00:00 2001 From: Anne Redulla Date: Wed, 11 Dec 2024 00:15:22 +0000 Subject: [PATCH] [win-bootstrap] Log warning if reading global Git config fails Logs a warning if reading the config fails. Still logs a warning for recommended settings, so the user can create their global config. Annoyingly, the exit code is the same for missing config file as it is for an existing but invalid file. Bug: b/382395049 Change-Id: I81113ff248f7a5eed2f9fd0303e0e81ae80d7d3e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6086756 Reviewed-by: Josip Sokcevic Commit-Queue: Anne Redulla --- bootstrap/bootstrap.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 404ee1ceb..8eb3c1a4f 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -351,10 +351,9 @@ def get_git_global_config(git_path): last value for each multivar will be in the returned config. Returns: - - dict of the current global git config. - - Raises: - subprocess.CalledProcessError if there was an error reading the config. + - GitConfigDict of the current global git config. + - If there was an error reading the global git config (e.g. file doesn't + exist, or is an invalid config), returns an empty GitConfigDict. """ try: # List all values in the global git config. Using the `-z` option allows @@ -366,7 +365,8 @@ def get_git_global_config(git_path): stdout=subprocess.PIPE, encoding='utf-8') except subprocess.CalledProcessError as e: - raise e + logging.warning(f'Failed to read your global Git config:\n{e}\n') + return GitConfigDict({}) # Process all entries in the config. config = {}