浏览代码

[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 <sokcevic@chromium.org>
Commit-Queue: Anne Redulla <aredulla@google.com>
Anne Redulla 8 月之前
父节点
当前提交
06029eb98c
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      bootstrap/bootstrap.py

+ 5 - 5
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 = {}