Implemented checks to ensure files with uncommitted changes or not present in previous commit cannot be undone safely.

This commit is contained in:
Paul Gauthier 2024-07-18 16:32:45 +01:00 committed by Paul Gauthier (aider)
parent e7f29c2dbc
commit 3ce3799f8d
2 changed files with 22 additions and 12 deletions

View file

@ -585,11 +585,12 @@ class TestCommands(TestCase):
last_commit_hash = repo.head.commit.hexsha[:7]
coder.aider_commit_hashes.add(last_commit_hash)
# Attempt to undo the last commit
# Attempt to undo the last commit, should refuse
commands.cmd_undo("")
# Check that the last commit was undone
self.assertNotEqual(last_commit_hash, repo.head.commit.hexsha[:7])
# Check that the last commit was not undone
self.assertEqual(last_commit_hash, repo.head.commit.hexsha[:7])
self.assertTrue(file_path.exists())
del coder
del commands