Commit graph

18 commits

Author SHA1 Message Date
Paul Gauthier
583c3285ec added tests, fixed bug 2023-10-18 10:31:45 -07:00
Paul Gauthier
6d5827643f don't try and commit unless there are changes #264 2023-09-25 14:55:00 -07:00
Paul Gauthier
285536105e Properly handle all diff cases 2023-08-18 10:07:47 -07:00
Paul Gauthier
6e9fbdcb6a fixed spurious "Adding to git" messages when running aider in subdir of repo 2023-08-17 08:32:44 -07:00
Paul Gauthier
a1da6cab24 ensure we diff properly in all cases, with tests #191 2023-08-10 15:33:53 -03:00
Paul Gauthier
af854182dc added failing test case for diffs of empty repo with new file added 2023-08-08 08:20:26 -03:00
Paul Gauthier
cac627ae5f aider: Add None as the third argument in all calls to GitRepo.
# Aider chat conversation:

USER: `GitRepo` now takes a 3rd arg. add None as the missing arg in all calls

ASSISTANT: To add `None` as the third argument in all calls to `GitRepo`, we need to modify the `tests/test_repo.py` file.

Here are the changes:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        repo = GitRepo(InputOutput(), None)
=======
        repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        tracked_files = GitRepo(InputOutput(), [tempdir]).get_tracked_files()
=======
        tracked_files = GitRepo(InputOutput(), [tempdir], None).get_tracked_files()
>>>>>>> UPDATED
```

```python
tests/test_repo.py
<<<<<<< ORIGINAL
            git_repo = GitRepo(InputOutput(), None)
=======
            git_repo = GitRepo(InputOutput(), None, None)
>>>>>>> UPDATED
```
2023-07-24 17:32:09 -03:00
Paul Gauthier
66da82094d use index.entries 2023-07-24 13:47:33 -03:00
Paul Gauthier
bef1d00ab1 Refactor test_get_tracked_files_with_new_staged_file to use a GitTemporaryDirectory and add new assertions. 2023-07-24 13:42:05 -03:00
Paul Gauthier
661a521693 aider.repo.simple_send_with_retries 2023-07-21 16:20:27 -03:00
Paul Gauthier
9f8ea93ce6 AiderRepo -> GitRepo 2023-07-21 16:08:27 -03:00
Paul Gauthier
1fcb090ff6 Refactor coder.get_tracked_files to coder.repo.get_tracked_files in test_coder.py and add test_get_commit_message_no_strip_unmatched_quotes in test_repo.py. 2023-07-21 14:36:26 -03:00
Paul Gauthier
e9090f8d61 Refactored creating a Coder object and getting tracked files in test_repo.py. 2023-07-21 14:32:20 -03:00
Paul Gauthier
b9dc419f19 Refactor test_get_commit_message_strip_quotes to use a mocked send_with_retries function and set the return value of the mocked function. 2023-07-21 14:30:33 -03:00
Paul Gauthier
1733fe4c90 aider: To match the return value of mock_send with commit_message = response.choices[0].message.content, modify the return value of mock_send in the test_get_commit_message function in the tests/test_repo.py file.
# Aider chat conversation:

USER: in `test_get_commit_message`, the mock_send return value needs to match the commit_message = response.choices[0].message.content

ASSISTANT: To match the return value of `mock_send` with `commit_message = response.choices[0].message.content`, we need to modify the return value of `mock_send` in the `test_get_commit_message` function in the `tests/test_repo.py` file.

The `send_with_retries` function returns a tuple where the second element is the response from the OpenAI API. The response is expected to be an object with a `choices` attribute, which is a list of objects, each with a `message` attribute, which in turn has a `content` attribute.

So, we need to return a mock response object that has these attributes. Here's how to do it:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
        mock_send.return_value = (
            None,
            "a good commit message"
        )
=======
        mock_response = MagicMock()
        mock_response.choices = [MagicMock()]
        mock_response.choices[0].message.content = "a good commit message"
        mock_send.return_value = (
            None,
            mock_response
        )
>>>>>>> UPDATED
```

This change will make the `mock_send` function return a mock response object that has the same structure as the actual response from the OpenAI API, allowing the `get_commit_message` method to correctly extract the commit message.
2023-07-21 14:29:15 -03:00
Paul Gauthier
a789de9433 Refactor test_get_commit_message to use the correct import and handle the return value of mock_send correctly. 2023-07-21 14:27:31 -03:00
Paul Gauthier
6f3b498228 aider: Set the return value of the mocked function aider.sendchat.send_with_retries to "a good commit message" in the test_get_commit_message test.
# Aider chat conversation:

USER: do the todo

ASSISTANT: To complete the TODO, we need to mock the return value of the function `aider.sendchat.send_with_retries`. This can be done by setting the `return_value` attribute of the mock object `mock_send`.

Here is the change:

```python
tests/test_repo.py
<<<<<<< ORIGINAL
    @patch("aider.sendchat.send_with_retries")
    def test_get_commit_message(self, mock_send):
        # TODO: make aider.sendchat.send_with_retries return "a good commit message"

        repo = AiderRepo(InputOutput(), None)
        # Call the get_commit_message method with dummy diff and context
        result = repo.get_commit_message("dummy diff", "dummy context")

        # Assert that the returned message is the expected one
        self.assertEqual(result, "a good commit_message")
=======
    @patch("aider.sendchat.send_with_retries")
    def test_get_commit_message(self, mock_send):
        # Set the return value of the mocked function
        mock_send.return_value = "a good commit message"

        repo = AiderRepo(InputOutput(), None)
        # Call the get_commit_message method with dummy diff and context
        result = repo.get_commit_message("dummy diff", "dummy context")

        # Assert that the returned message is the expected one
        self.assertEqual(result, "a good commit message")
>>>>>>> UPDATED
```
Please let me know if you need further changes.
2023-07-21 14:24:49 -03:00
Paul Gauthier
ebd8d9725b wip 2023-07-21 14:24:19 -03:00