From 56210468f748257db65dd2ef6467779ffb177ad8 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 19 Aug 2024 15:41:09 -0700 Subject: [PATCH] feat: Use GitTemporaryDirectory and import git instead of os.system --- tests/basic/test_repomap.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/basic/test_repomap.py b/tests/basic/test_repomap.py index 93ddd8687..280203adb 100644 --- a/tests/basic/test_repomap.py +++ b/tests/basic/test_repomap.py @@ -1,11 +1,13 @@ import os import unittest +import git + from aider.dump import dump # noqa: F401 from aider.io import InputOutput from aider.models import Model from aider.repomap import RepoMap -from aider.utils import IgnorantTemporaryDirectory +from aider.utils import GitTemporaryDirectory, IgnorantTemporaryDirectory class TestRepoMap(unittest.TestCase): @@ -41,9 +43,8 @@ class TestRepoMap(unittest.TestCase): del repo_map def test_repo_map_refresh_files(self): - with IgnorantTemporaryDirectory() as temp_dir: - # Create a small git repo - os.system(f"git init {temp_dir}") + with GitTemporaryDirectory() as temp_dir: + repo = git.Repo(temp_dir) # Create two source files with one function each file1_content = "def function1():\n return 'Hello from file1'\n" @@ -55,7 +56,8 @@ class TestRepoMap(unittest.TestCase): f.write(file2_content) # 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 io = InputOutput()