aider: Set default values for input and chat history files to be in the git root directory if there is one, otherwise, use the current directory.

# Context:
USER: have the input and chat history files default to be located in the git root, if there is one
ASSISTANT: To change the default location of the input and chat history files to the git root, you need to modify the `aider/main.py` file. Update the default values for `--input-history-file` and `--chat-history-file` arguments.

Here's the change:

```python
aider/main.py
<<<<<<< ORIGINAL
    parser.add_argument(
        "--input-history-file",
        metavar="INPUT_HISTORY_FILE",
        env_var=f"{env_prefix}INPUT_HISTORY_FILE",
        default=".aider.input.history",
        help="Specify the chat input history file (default: .aider.input.history)",
    )
    parser.add_argument(
        "--chat-history-file",
        metavar="CHAT_HISTORY_FILE",
        env_var=f"{env_prefix}CHAT_HISTORY_FILE",
        default=".aider.chat.history.md",
        help="Specify the chat history file (default: .aider.chat.history.md)",
    )
=======
    default_input_history_file = os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history"
    default_chat_history_file = os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md"

    parser.add_argument(
        "--input-history-file",
        metavar="INPUT_HISTORY_FILE",
        env_var=f"{env_prefix}INPUT_HISTORY_FILE",
        default=default_input_history_file,
        help=f"Specify the chat input history file (default: {default_input_history_file})",
    )
    parser.add_argument(
        "--chat-history-file",
        metavar="CHAT_HISTORY_FILE",
        env_var=f"{env_prefix}CHAT_HISTORY_FILE",
        default=default_chat_history_file,
        help=f"Specify the chat history file (default: {default_chat_history_file})",
    )
>>>>>>> UPDATED
```

This change sets the default values for the input and chat history files to be in the git root directory if there is one, otherwise, it will use the current directory.
This commit is contained in:
Paul Gauthier 2023-05-26 16:22:49 -07:00
parent e4116007b8
commit ddc97dacf8

View file

@ -41,19 +41,22 @@ def main(args=None, input=None, output=None):
nargs="*", nargs="*",
help="a list of source code files (optional)", help="a list of source code files (optional)",
) )
default_input_history_file = os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history"
default_chat_history_file = os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md"
parser.add_argument( parser.add_argument(
"--input-history-file", "--input-history-file",
metavar="INPUT_HISTORY_FILE", metavar="INPUT_HISTORY_FILE",
env_var=f"{env_prefix}INPUT_HISTORY_FILE", env_var=f"{env_prefix}INPUT_HISTORY_FILE",
default=".aider.input.history", default=default_input_history_file,
help="Specify the chat input history file (default: .aider.input.history)", help=f"Specify the chat input history file (default: {default_input_history_file})",
) )
parser.add_argument( parser.add_argument(
"--chat-history-file", "--chat-history-file",
metavar="CHAT_HISTORY_FILE", metavar="CHAT_HISTORY_FILE",
env_var=f"{env_prefix}CHAT_HISTORY_FILE", env_var=f"{env_prefix}CHAT_HISTORY_FILE",
default=".aider.chat.history.md", default=default_chat_history_file,
help="Specify the chat history file (default: .aider.chat.history.md)", help=f"Specify the chat history file (default: {default_chat_history_file})",
) )
parser.add_argument( parser.add_argument(
"--model", "--model",