A new file should get pre-committed before the GPT edit commit
(self)
| 568 | self.assertEqual(len(coder.abs_fnames), 2) |
| 569 | |
| 570 | def test_new_file_edit_one_commit(self): |
| 571 | """A new file should get pre-committed before the GPT edit commit""" |
| 572 | with GitTemporaryDirectory(): |
| 573 | repo = git.Repo() |
| 574 | |
| 575 | fname = Path("file.txt") |
| 576 | |
| 577 | io = InputOutput(yes=True) |
| 578 | coder = Coder.create(self.GPT35, "diff", io=io, fnames=[str(fname)]) |
| 579 | |
| 580 | self.assertTrue(fname.exists()) |
| 581 | |
| 582 | # make sure it was not committed |
| 583 | with self.assertRaises(git.exc.GitCommandError): |
| 584 | list(repo.iter_commits(repo.active_branch.name)) |
| 585 | |
| 586 | def mock_send(*args, **kwargs): |
| 587 | coder.partial_response_content = f""" |
| 588 | Do this: |
| 589 | |
| 590 | {str(fname)} |
| 591 | <<<<<<< SEARCH |
| 592 | ======= |
| 593 | new |
| 594 | >>>>>>> REPLACE |
| 595 | |
| 596 | """ |
| 597 | coder.partial_response_function_call = dict() |
| 598 | return [] |
| 599 | |
| 600 | coder.send = mock_send |
| 601 | coder.repo.get_commit_message = MagicMock() |
| 602 | coder.repo.get_commit_message.return_value = "commit message" |
| 603 | |
| 604 | coder.run(with_message="hi") |
| 605 | |
| 606 | content = fname.read_text() |
| 607 | self.assertEqual(content, "new\n") |
| 608 | |
| 609 | num_commits = len(list(repo.iter_commits(repo.active_branch.name))) |
| 610 | self.assertEqual(num_commits, 2) |
| 611 | |
| 612 | def test_only_commit_gpt_edited_file(self): |
| 613 | """ |
nothing calls this directly
no test coverage detected