fix: Handle GitCommandError when retrieving git user config

This commit is contained in:
Paul Gauthier (aider) 2025-03-11 08:27:17 -07:00
parent a3c0d628a1
commit 987d024847

View file

@ -126,8 +126,15 @@ def setup_git(git_root, io):
if not repo:
return
user_name = repo.git.config("--get", "user.name") or None
user_email = repo.git.config("--get", "user.email") or None
try:
user_name = repo.git.config("--get", "user.name") or None
except git.exc.GitCommandError:
user_name = None
try:
user_email = repo.git.config("--get", "user.email") or None
except git.exc.GitCommandError:
user_email = None
if user_name and user_email:
return repo.working_tree_dir