merging from upstream main

This commit is contained in:
Joshua Vial 2023-12-19 22:04:39 +13:00
commit 179b648864
29 changed files with 3810 additions and 114 deletions

View file

@ -10,7 +10,7 @@ from aider import models
from aider.coders import Coder
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from tests.utils import ChdirTemporaryDirectory, GitTemporaryDirectory
from aider.utils import ChdirTemporaryDirectory, GitTemporaryDirectory
class TestCoder(unittest.TestCase):

View file

@ -14,7 +14,7 @@ from aider.coders import Coder
from aider.commands import Commands
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from tests.utils import ChdirTemporaryDirectory, GitTemporaryDirectory, make_repo
from aider.utils import ChdirTemporaryDirectory, GitTemporaryDirectory, make_repo
class TestCommands(TestCase):

View file

@ -4,7 +4,7 @@ from pathlib import Path
from unittest.mock import patch
from aider.io import AutoCompleter, InputOutput
from tests.utils import ChdirTemporaryDirectory
from aider.utils import ChdirTemporaryDirectory
class TestInputOutput(unittest.TestCase):

View file

@ -13,7 +13,7 @@ from prompt_toolkit.output import DummyOutput
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from aider.main import check_gitignore, main, setup_git
from tests.utils import GitTemporaryDirectory, make_repo
from aider.utils import GitTemporaryDirectory, make_repo
class TestMain(TestCase):

View file

@ -9,7 +9,7 @@ import git
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from aider.repo import GitRepo
from tests.utils import GitTemporaryDirectory
from aider.utils import GitTemporaryDirectory
class TestRepo(unittest.TestCase):

View file

@ -4,7 +4,7 @@ import unittest
from aider.dump import dump # noqa: F401
from aider.io import InputOutput
from aider.repomap import RepoMap
from tests.utils import IgnorantTemporaryDirectory
from aider.utils import IgnorantTemporaryDirectory
class TestRepoMap(unittest.TestCase):

View file

@ -1,56 +0,0 @@
import os
import tempfile
import git
from aider.dump import dump # noqa: F401
class IgnorantTemporaryDirectory:
def __init__(self):
self.temp_dir = tempfile.TemporaryDirectory()
def __enter__(self):
return self.temp_dir.__enter__()
def __exit__(self, exc_type, exc_val, exc_tb):
try:
self.temp_dir.__exit__(exc_type, exc_val, exc_tb)
except (OSError, PermissionError):
pass # Ignore errors (Windows)
class ChdirTemporaryDirectory(IgnorantTemporaryDirectory):
def __init__(self):
self.cwd = os.getcwd()
super().__init__()
def __enter__(self):
res = super().__enter__()
os.chdir(self.temp_dir.name)
return res
def __exit__(self, exc_type, exc_val, exc_tb):
os.chdir(self.cwd)
super().__exit__(exc_type, exc_val, exc_tb)
class GitTemporaryDirectory(ChdirTemporaryDirectory):
def __enter__(self):
res = super().__enter__()
self.repo = make_repo()
return res
def __exit__(self, exc_type, exc_val, exc_tb):
del self.repo
super().__exit__(exc_type, exc_val, exc_tb)
def make_repo(path=None):
if not path:
path = "."
repo = git.Repo.init(path)
repo.config_writer().set_value("user", "name", "Test User").release()
repo.config_writer().set_value("user", "email", "testuser@example.com").release()
return repo