mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
Merge branch 'main' into mixpanel
This commit is contained in:
commit
97989dd51a
5 changed files with 24 additions and 12 deletions
|
@ -1,4 +1,3 @@
|
||||||
# ai
|
|
||||||
import configparser
|
import configparser
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -6,6 +5,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
import webbrowser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import git
|
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_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("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("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
|
return False
|
||||||
|
|
||||||
io.tool_error("Unable to read git repository, it may be corrupt?")
|
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)
|
problem = models.sanity_check_models(io, main_model)
|
||||||
if problem:
|
if problem:
|
||||||
io.tool_output("You can skip this check with --no-show-model-warnings")
|
io.tool_output("You can skip this check with --no-show-model-warnings")
|
||||||
io.tool_output()
|
|
||||||
try:
|
try:
|
||||||
if not io.confirm_ask("Proceed anyway?"):
|
if io.confirm_ask(
|
||||||
return 1
|
"Open documentation url for more info?", subject=urls.model_warnings
|
||||||
|
):
|
||||||
|
webbrowser.open(urls.model_warnings)
|
||||||
|
io.tool_output()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -845,7 +849,11 @@ def check_and_load_imports(io, verbose=False):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
io.tool_error(str(err))
|
io.tool_error(str(err))
|
||||||
io.tool_output("Error loading required imports. Did you install aider properly?")
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
installs[str(key)] = True
|
installs[str(key)] = True
|
||||||
|
|
|
@ -13,7 +13,6 @@ import json5
|
||||||
import yaml
|
import yaml
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from aider import urls
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.llm import litellm
|
from aider.llm import litellm
|
||||||
|
|
||||||
|
@ -1042,9 +1041,6 @@ def sanity_check_model(io, model):
|
||||||
for match in possible_matches:
|
for match in possible_matches:
|
||||||
io.tool_output(f"- {match}")
|
io.tool_output(f"- {match}")
|
||||||
|
|
||||||
if show:
|
|
||||||
io.tool_output(f"For more info, see: {urls.model_warnings}")
|
|
||||||
|
|
||||||
return show
|
return show
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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"
|
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"
|
github_issues = "https://github.com/Aider-AI/aider/issues/new"
|
||||||
git_index_version = "https://github.com/Aider-AI/aider/issues/211"
|
git_index_version = "https://github.com/Aider-AI/aider/issues/211"
|
||||||
|
install_properly = "https://aider.chat/docs/troubleshooting/imports.html"
|
||||||
|
|
|
@ -32,6 +32,8 @@ class TestMain(TestCase):
|
||||||
os.environ["HOME"] = self.homedir_obj.name
|
os.environ["HOME"] = self.homedir_obj.name
|
||||||
self.input_patcher = patch("builtins.input", return_value=None)
|
self.input_patcher = patch("builtins.input", return_value=None)
|
||||||
self.mock_input = self.input_patcher.start()
|
self.mock_input = self.input_patcher.start()
|
||||||
|
self.webbrowser_patcher = patch("webbrowser.open")
|
||||||
|
self.mock_webbrowser = self.webbrowser_patcher.start()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.chdir(self.original_cwd)
|
os.chdir(self.original_cwd)
|
||||||
|
@ -40,6 +42,7 @@ class TestMain(TestCase):
|
||||||
os.environ.clear()
|
os.environ.clear()
|
||||||
os.environ.update(self.original_env)
|
os.environ.update(self.original_env)
|
||||||
self.input_patcher.stop()
|
self.input_patcher.stop()
|
||||||
|
self.webbrowser_patcher.stop()
|
||||||
|
|
||||||
def test_main_with_empty_dir_no_files_on_command(self):
|
def test_main_with_empty_dir_no_files_on_command(self):
|
||||||
main(["--no-git", "--exit"], input=DummyInput(), output=DummyOutput())
|
main(["--no-git", "--exit"], input=DummyInput(), output=DummyOutput())
|
||||||
|
|
|
@ -6,6 +6,7 @@ from unittest import mock
|
||||||
import pytest
|
import pytest
|
||||||
from git import GitError, Repo
|
from git import GitError, Repo
|
||||||
|
|
||||||
|
from aider import urls
|
||||||
from aider.main import sanity_check_repo
|
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()
|
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
|
repo_path, repo = create_repo
|
||||||
# Set the git index version to 3
|
# Set the git index version to 3
|
||||||
set_git_index_version(str(repo_path), 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"
|
"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("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):
|
def test_bare_repository(create_repo, mock_io, tmp_path):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue