From 108abe4a49d45686d93d6a71b8506bc66087b1d2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jul 2023 12:26:31 -0300 Subject: [PATCH] aider: Replace all `subprocess.run(git` calls that are making new repos and setting config with `make_repo` calls. # Aider chat conversation: USER: replace all the `subprocess.run(git` calls that are making new repos and setting config with `make_repo` calls ASSISTANT: To replace all the `subprocess.run(git` calls that are making new repos and setting config with `make_repo` calls, we need to modify the `tests/test_main.py` file. Here are the changes: ```python tests/test_main.py <<<<<<< ORIGINAL subprocess.run(["git", "init"]) subprocess.run(["git", "config", "user.email", "dummy@example.com"]) subprocess.run(["git", "config", "user.name", "Dummy User"]) ======= from tests.utils import make_repo make_repo() >>>>>>> UPDATED ``` ```python tests/test_main.py <<<<<<< ORIGINAL subprocess.run(["git", "init"]) subprocess.run(["git", "config", "user.email", "dummy@example.com"]) subprocess.run(["git", "config", "user.name", "Dummy User"]) ======= from tests.utils import make_repo make_repo() >>>>>>> UPDATED ``` ```python tests/test_main.py <<<<<<< ORIGINAL subprocess.run(["git", "init"]) subprocess.run(["git", "config", "user.email", "dummy@example.com"]) subprocess.run(["git", "config", "user.name", "Dummy User"]) ======= from tests.utils import make_repo make_repo() >>>>>>> UPDATED ``` Please note that you need to import the `make_repo` function from `tests.utils` in each test where it's used. --- tests/test_main.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index cc6fa8705..41e1717bc 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -38,16 +38,14 @@ class TestMain(TestCase): self.assertTrue(os.path.exists("foo.txt")) def test_main_with_empty_git_dir_new_file(self): - subprocess.run(["git", "init"]) - subprocess.run(["git", "config", "user.email", "dummy@example.com"]) - subprocess.run(["git", "config", "user.name", "Dummy User"]) + from tests.utils import make_repo + make_repo() main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) def test_main_with_git_config_yml(self): - subprocess.run(["git", "init"]) - subprocess.run(["git", "config", "user.email", "dummy@example.com"]) - subprocess.run(["git", "config", "user.name", "Dummy User"]) + from tests.utils import make_repo + make_repo() Path(".aider.conf.yml").write_text("no-auto-commits: true\n") with patch("aider.main.Coder.create") as MockCoder: @@ -62,9 +60,8 @@ class TestMain(TestCase): assert kwargs["auto_commits"] is True def test_main_with_empty_git_dir_new_subdir_file(self): - subprocess.run(["git", "init"]) - subprocess.run(["git", "config", "user.email", "dummy@example.com"]) - subprocess.run(["git", "config", "user.name", "Dummy User"]) + from tests.utils import make_repo + make_repo() subdir = Path("subdir") subdir.mkdir() fname = subdir / "foo.txt"