diff --git a/aider/commands.py b/aider/commands.py index f6b0c3cba..58fa7d6c6 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -332,7 +332,7 @@ class Commands: last_commit = self.coder.repo.repo.head.commit if ( - not last_commit.message.startswith("aider:") + "(aider)" not in last_commit.committer.name or last_commit.hexsha[:7] != self.coder.last_aider_commit_hash ): self.io.tool_error("The last commit was not made by aider in this chat session.") diff --git a/aider/tests/test_commands.py b/aider/tests/test_commands.py index 8cc67b6d8..2fa84817b 100644 --- a/aider/tests/test_commands.py +++ b/aider/tests/test_commands.py @@ -523,16 +523,20 @@ class TestCommands(TestCase): other_path.write_text("other content") repo.git.add(str(other_path)) + os.environ["GIT_COMMITTER_NAME"] = "Foo (aider)" + # Create and commit a file filename = "test_file.txt" file_path = Path(repo_dir) / filename file_path.write_text("first content") repo.git.add(filename) - repo.git.commit("-m", "aider: first commit") + repo.git.commit("-m", "first commit") file_path.write_text("second content") repo.git.add(filename) - repo.git.commit("-m", "aider: second commit") + repo.git.commit("-m", "second commit") + + del os.environ["GIT_COMMITTER_NAME"] # Store the commit hash last_commit_hash = repo.head.commit.hexsha[:7]