mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
feat: Use GitTemporaryDirectory and import git instead of os.system
This commit is contained in:
parent
b0d8778752
commit
56210468f7
1 changed files with 7 additions and 5 deletions
|
@ -1,11 +1,13 @@
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import git
|
||||||
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
from aider.models import Model
|
from aider.models import Model
|
||||||
from aider.repomap import RepoMap
|
from aider.repomap import RepoMap
|
||||||
from aider.utils import IgnorantTemporaryDirectory
|
from aider.utils import GitTemporaryDirectory, IgnorantTemporaryDirectory
|
||||||
|
|
||||||
|
|
||||||
class TestRepoMap(unittest.TestCase):
|
class TestRepoMap(unittest.TestCase):
|
||||||
|
@ -41,9 +43,8 @@ class TestRepoMap(unittest.TestCase):
|
||||||
del repo_map
|
del repo_map
|
||||||
|
|
||||||
def test_repo_map_refresh_files(self):
|
def test_repo_map_refresh_files(self):
|
||||||
with IgnorantTemporaryDirectory() as temp_dir:
|
with GitTemporaryDirectory() as temp_dir:
|
||||||
# Create a small git repo
|
repo = git.Repo(temp_dir)
|
||||||
os.system(f"git init {temp_dir}")
|
|
||||||
|
|
||||||
# Create two source files with one function each
|
# Create two source files with one function each
|
||||||
file1_content = "def function1():\n return 'Hello from file1'\n"
|
file1_content = "def function1():\n return 'Hello from file1'\n"
|
||||||
|
@ -55,7 +56,8 @@ class TestRepoMap(unittest.TestCase):
|
||||||
f.write(file2_content)
|
f.write(file2_content)
|
||||||
|
|
||||||
# Add files to git
|
# Add files to git
|
||||||
os.system(f"cd {temp_dir} && git add . && git commit -m 'Initial commit'")
|
repo.index.add(["file1.py", "file2.py"])
|
||||||
|
repo.index.commit("Initial commit")
|
||||||
|
|
||||||
# Initialize RepoMap with refresh="files" and one source file
|
# Initialize RepoMap with refresh="files" and one source file
|
||||||
io = InputOutput()
|
io = InputOutput()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue