Merge branch 'main' into mixpanel

This commit is contained in:
Paul Gauthier 2024-10-30 12:06:38 -07:00
commit 97989dd51a
5 changed files with 24 additions and 12 deletions

View file

@ -1,4 +1,3 @@
# ai
import configparser
import json
import os
@ -6,6 +5,7 @@ import re
import sys
import threading
import traceback
import webbrowser
from pathlib import Path
import git
@ -367,7 +367,8 @@ def sanity_check_repo(repo, io):
io.tool_error("Aider only works with git repos with version number 1 or 2.")
io.tool_output("You may be able to convert your repo: git update-index --index-version=2")
io.tool_output("Or run aider --no-git to proceed without using git.")
io.tool_output(urls.git_index_version)
if io.confirm_ask("Open documentation url for more info?", subject=urls.git_index_version):
webbrowser.open(urls.git_index_version)
return False
io.tool_error("Unable to read git repository, it may be corrupt?")
@ -618,10 +619,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
problem = models.sanity_check_models(io, main_model)
if problem:
io.tool_output("You can skip this check with --no-show-model-warnings")
io.tool_output()
try:
if not io.confirm_ask("Proceed anyway?"):
return 1
if io.confirm_ask(
"Open documentation url for more info?", subject=urls.model_warnings
):
webbrowser.open(urls.model_warnings)
io.tool_output()
except KeyboardInterrupt:
return 1
@ -845,7 +849,11 @@ def check_and_load_imports(io, verbose=False):
except Exception as err:
io.tool_error(str(err))
io.tool_output("Error loading required imports. Did you install aider properly?")
io.tool_output("https://aider.chat/docs/install/install.html")
if io.confirm_ask(
"Open documentation url for more info?", subject=urls.install_properly
):
webbrowser.open(urls.install_properly)
sys.exit(1)
installs[str(key)] = True

View file

@ -13,7 +13,6 @@ import json5
import yaml
from PIL import Image
from aider import urls
from aider.dump import dump # noqa: F401
from aider.llm import litellm
@ -1042,9 +1041,6 @@ def sanity_check_model(io, model):
for match in possible_matches:
io.tool_output(f"- {match}")
if show:
io.tool_output(f"For more info, see: {urls.model_warnings}")
return show

View file

@ -10,3 +10,4 @@ llms = "https://aider.chat/docs/llms.html"
large_repos = "https://aider.chat/docs/faq.html#can-i-use-aider-in-a-large-mono-repo"
github_issues = "https://github.com/Aider-AI/aider/issues/new"
git_index_version = "https://github.com/Aider-AI/aider/issues/211"
install_properly = "https://aider.chat/docs/troubleshooting/imports.html"

View file

@ -32,6 +32,8 @@ class TestMain(TestCase):
os.environ["HOME"] = self.homedir_obj.name
self.input_patcher = patch("builtins.input", return_value=None)
self.mock_input = self.input_patcher.start()
self.webbrowser_patcher = patch("webbrowser.open")
self.mock_webbrowser = self.webbrowser_patcher.start()
def tearDown(self):
os.chdir(self.original_cwd)
@ -40,6 +42,7 @@ class TestMain(TestCase):
os.environ.clear()
os.environ.update(self.original_env)
self.input_patcher.stop()
self.webbrowser_patcher.stop()
def test_main_with_empty_dir_no_files_on_command(self):
main(["--no-git", "--exit"], input=DummyInput(), output=DummyOutput())

View file

@ -6,6 +6,7 @@ from unittest import mock
import pytest
from git import GitError, Repo
from aider import urls
from aider.main import sanity_check_repo
@ -99,7 +100,8 @@ def test_detached_head_state(create_repo, mock_io):
mock_io.tool_output.assert_not_called()
def test_git_index_version_greater_than_2(create_repo, mock_io):
@mock.patch("webbrowser.open")
def test_git_index_version_greater_than_2(mock_browser, create_repo, mock_io):
repo_path, repo = create_repo
# Set the git index version to 3
set_git_index_version(str(repo_path), 3)
@ -125,7 +127,9 @@ def test_git_index_version_greater_than_2(create_repo, mock_io):
"You may be able to convert your repo: git update-index --index-version=2"
)
mock_io.tool_output.assert_any_call("Or run aider --no-git to proceed without using git.")
mock_io.tool_output.assert_any_call("https://github.com/Aider-AI/aider/issues/211")
mock_io.confirm_ask.assert_any_call(
"Open documentation url for more info?", subject=urls.git_index_version
)
def test_bare_repository(create_repo, mock_io, tmp_path):