Merge pull request #3423 from akirak/git-config

Retrieve the identity using git-config command
This commit is contained in:
paul-gauthier 2025-03-05 16:21:00 -08:00 committed by GitHub
commit e6e692dc43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 12 deletions

View file

@ -126,17 +126,8 @@ def setup_git(git_root, io):
if not repo:
return
user_name = None
user_email = None
with repo.config_reader() as config:
try:
user_name = config.get_value("user", "name", None)
except (configparser.NoSectionError, configparser.NoOptionError):
pass
try:
user_email = config.get_value("user", "email", None)
except (configparser.NoSectionError, configparser.NoOptionError):
pass
user_name = repo.git.config("--default", "", "--get", "user.name") or None
user_email = repo.git.config("--default", "", "--get", "user.email") or None
if user_name and user_email:
return repo.working_tree_dir