mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
aider: Change the code to check the global git configuration for the user name and email when creating a repo.
# Aider chat conversation: USER: i have a global git name and email, but the git create code here isn't noticing and is setting the example name/email when it makes a repo ASSISTANT: To fix this, we need to modify the `main` function in the `aider/main.py` file. Specifically, we need to change the way it checks for the global git name and email. Instead of checking the local git configuration, we should check the global git configuration. Here is the change: ```python aider/main.py <<<<<<< ORIGINAL with repo.config_writer() as git_config: if not git_config.has_option("user", "name"): git_config.set_value("user", "name", "Your Name") io.tool_error('Update git name with: git config --global user.name "Your Name"') if not git_config.has_option("user", "email"): git_config.set_value("user", "email", "you@example.com") io.tool_error( 'Update git email with: git config --global user.email "you@example.com"' ) ======= global_git_config = git.GitConfigParser([os.path.expanduser("~/.gitconfig")], read_only=True) with repo.config_writer() as git_config: if not global_git_config.has_option("user", "name"): git_config.set_value("user", "name", "Your Name") io.tool_error('Update git name with: git config --global user.name "Your Name"') if not global_git_config.has_option("user", "email"): git_config.set_value("user", "email", "you@example.com") io.tool_error( 'Update git email with: git config --global user.email "you@example.com"' ) >>>>>>> UPDATED ``` This change will make the code check the global git configuration (`~/.gitconfig`) for the user name and email. If they are not found, it will set the local git configuration with the example name and email and display a message to the user to update their global git configuration.
This commit is contained in:
parent
f6b0d2b225
commit
3a6112377f
1 changed files with 3 additions and 2 deletions
|
@ -296,11 +296,12 @@ def main(args=None, input=None, output=None):
|
|||
if not git_root and args.git:
|
||||
if io.confirm_ask("No git repo found, create one to track GPT's changes (recommended)?"):
|
||||
repo = git.Repo.init(os.getcwd())
|
||||
global_git_config = git.GitConfigParser([os.path.expanduser("~/.gitconfig")], read_only=True)
|
||||
with repo.config_writer() as git_config:
|
||||
if not git_config.has_option("user", "name"):
|
||||
if not global_git_config.has_option("user", "name"):
|
||||
git_config.set_value("user", "name", "Your Name")
|
||||
io.tool_error('Update git name with: git config --global user.name "Your Name"')
|
||||
if not git_config.has_option("user", "email"):
|
||||
if not global_git_config.has_option("user", "email"):
|
||||
git_config.set_value("user", "email", "you@example.com")
|
||||
io.tool_error(
|
||||
'Update git email with: git config --global user.email "you@example.com"'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue