mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
Fixed quote stripping of gpt3.5 commit messages
This commit is contained in:
parent
3d8ecddb3f
commit
bd78789bd2
2 changed files with 36 additions and 1 deletions
|
@ -516,7 +516,9 @@ class Coder:
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
commit_message = commit_message.strip().strip('"').strip()
|
commit_message = commit_message.strip()
|
||||||
|
if commit_message and commit_message[0] == '"' and commit_message[-1] == '"':
|
||||||
|
commit_message = commit_message[1:-1].strip()
|
||||||
|
|
||||||
if interrupted:
|
if interrupted:
|
||||||
self.io.tool_error(
|
self.io.tool_error(
|
||||||
|
|
|
@ -76,5 +76,38 @@ class TestCoder(unittest.TestCase):
|
||||||
# Assert that the returned message is the expected one
|
# Assert that the returned message is the expected one
|
||||||
self.assertEqual(result, "a good commit message")
|
self.assertEqual(result, "a good commit message")
|
||||||
|
|
||||||
|
def test_get_commit_message_strip_quotes(self):
|
||||||
|
# Mock the IO object
|
||||||
|
mock_io = MagicMock()
|
||||||
|
|
||||||
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
|
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||||
|
|
||||||
|
# Mock the send method to return a tuple with a message and False
|
||||||
|
coder.send = MagicMock(return_value=('"a good commit message"', False))
|
||||||
|
|
||||||
|
# Call the get_commit_message method with dummy diff and context
|
||||||
|
result = coder.get_commit_message("dummy diff", "dummy context")
|
||||||
|
|
||||||
|
# Assert that the returned message is the expected one
|
||||||
|
self.assertEqual(result, "a good commit message")
|
||||||
|
|
||||||
|
def test_get_commit_message_no_strip_unmatched_quotes(self):
|
||||||
|
# Mock the IO object
|
||||||
|
mock_io = MagicMock()
|
||||||
|
|
||||||
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
|
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||||
|
|
||||||
|
# Mock the send method to return a tuple with a message and False
|
||||||
|
coder.send = MagicMock(return_value=('a good "commit message"', False))
|
||||||
|
|
||||||
|
# Call the get_commit_message method with dummy diff and context
|
||||||
|
result = coder.get_commit_message("dummy diff", "dummy context")
|
||||||
|
|
||||||
|
# Assert that the returned message is the expected one
|
||||||
|
self.assertEqual(result, 'a good "commit message"')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue