aider: Added functionality to load .env file from git_root if available.

# Context:
USER: load_dotenv from the git_root if avail
ASSISTANT: To load the `.env` file from the `git_root` if available, you can modify the `load_dotenv()` function call in `aider/main.py`. Here's the change:

```python
aider/main.py
<<<<<<< ORIGINAL
    load_dotenv()
=======
    if git_root:
        load_dotenv(os.path.join(git_root, ".env"))
    else:
        load_dotenv()
>>>>>>> UPDATED
```

This change checks if `git_root` is available and loads the `.env` file from the `git_root` directory. If `git_root` is not available, it falls back to the default behavior of loading the `.env` file from the current working directory.
This commit is contained in:
Paul Gauthier 2023-05-27 05:15:05 -07:00
parent a1ff34d084
commit e02b612126

View file

@ -19,13 +19,17 @@ def main(args=None, input=None, output=None):
if args is None: if args is None:
args = sys.argv[1:] args = sys.argv[1:]
load_dotenv() git_root = get_git_root()
if git_root:
load_dotenv(os.path.join(git_root, ".env"))
else:
load_dotenv()
env_prefix = "AIDER_" env_prefix = "AIDER_"
default_config_files = [ default_config_files = [
os.path.expanduser("~/.aider.conf.yml"), os.path.expanduser("~/.aider.conf.yml"),
] ]
git_root = get_git_root()
if git_root: if git_root:
default_config_files.insert(0, os.path.join(git_root, ".aider.conf.yml")) default_config_files.insert(0, os.path.join(git_root, ".aider.conf.yml"))