added test for #310

This commit is contained in:
Paul Gauthier 2023-11-02 09:45:16 -07:00
parent b507ea087f
commit 6556265c23

View file

@ -413,3 +413,22 @@ class TestCommands(TestCase):
commands.cmd_add(f'"{fname}"') commands.cmd_add(f'"{fname}"')
self.assertIn(str(fname.resolve()), coder.abs_fnames) self.assertIn(str(fname.resolve()), coder.abs_fnames)
def test_cmd_add_no_autocommit(self):
with GitTemporaryDirectory():
io = InputOutput(pretty=False, yes=True)
from aider.coders import Coder
coder = Coder.create(models.GPT35, None, io, auto_commits=False)
commands = Commands(io, coder)
commands.cmd_add("foo.txt")
# Check if both files have been created in the temporary directory
self.assertTrue(os.path.exists("foo.txt"))
repo = git.Repo()
# Assert that foo.txt has been `git add` but not `git commit`
added_files = repo.git.diff("--cached", "--name-only").split()
self.assertIn("foo.txt", added_files)