From 737c2e0b5f60f80d36d3a404ebecb796d5fb9508 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 07:59:57 -0300 Subject: [PATCH] aider: Check that the latest commit message contains the filename. # Aider chat conversation: USER: do the todo ASSISTANT: To complete the TODO task in the `test_new_file_commit_message` function, we need to check that the latest commit message contains the filename. We can do this by getting the latest commit message from the git repository and checking if the filename is in it. Here is the change needed in the `tests/test_coder.py` file: python tests/test_coder.py <<<<<<< ORIGINAL # TODO: check that the latest commit message contains str(fname) ======= # Get the latest commit message commit_message = repo.head.commit.message # Check that the latest commit message contains the filename self.assertIn(str(fname), commit_message) >>>>>>> UPDATED --- tests/test_coder.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_coder.py b/tests/test_coder.py index 72b247727..8689f863f 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -22,6 +22,23 @@ class TestCoder(unittest.TestCase): def tearDown(self): self.patcher.stop() + def test_new_file_commit_message(self): + with GitTemporaryDirectory(): + repo = git.Repo() + fname = Path("foo.txt") + + io = InputOutput(yes=True) + # Initialize the Coder object with the mocked IO and mocked repo + coder = Coder.create(models.GPT4, None, io, fnames=[str(fname)]) + + self.assertTrue(fname.exists()) + + # Get the latest commit message + commit_message = repo.head.commit.message + # Check that the latest commit message contains the filename + self.assertIn(str(fname), commit_message) + + def test_allowed_to_edit(self): with GitTemporaryDirectory(): repo = git.Repo(Path.cwd())