diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 662bd7912..f6c8f7174 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -48,6 +48,7 @@ class Coder: abs_fnames = None repo = None last_aider_commit_hash = None + aider_commit_hashes = set() aider_edited_files = None last_asked_for_commit_time = 0 repo_map = None @@ -115,6 +116,7 @@ class Coder: fnames=from_coder.get_inchat_relative_files(), done_messages=done_messages, cur_messages=from_coder.cur_messages, + aider_commit_hashes=from_coder.aider_commit_hashes, ) use_kwargs.update(update) # override to complete the switch @@ -222,6 +224,7 @@ class Coder: attribute_author=True, attribute_committer=True, attribute_commit_message=False, + aider_commit_hashes=None, ): if not fnames: fnames = [] @@ -229,6 +232,11 @@ class Coder: if io is None: io = InputOutput() + if aider_commit_hashes: + self.aider_commit_hashes = aider_commit_hashes + else: + self.aider_commit_hashes = set() + self.chat_completion_call_hashes = [] self.chat_completion_response_hashes = [] self.need_commit_before_edits = set() @@ -1451,6 +1459,7 @@ class Coder: if res: commit_hash, commit_message = res self.last_aider_commit_hash = commit_hash + self.aider_commit_hashes.add(commit_hash) self.last_aider_commit_message = commit_message if self.show_diffs: self.commands.cmd_diff() diff --git a/aider/commands.py b/aider/commands.py index 2cc18ab54..b50138c2b 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -346,16 +346,12 @@ class Commands: # Move the HEAD back before the latest commit self.coder.repo.repo.git.reset("--soft", "HEAD~1") - self.io.tool_output( - f"Commit `{last_commit_hash}` with message '{last_commit_message}' was reset and removed from git." - ) + self.io.tool_output(f"Removed: {last_commit_hash} {last_commit_message}") # Get the current HEAD after undo current_head_hash = self.coder.repo.repo.head.commit.hexsha[:7] current_head_message = self.coder.repo.repo.head.commit.message.strip() - self.io.tool_output( - f"Current HEAD is now `{current_head_hash}` with message '{current_head_message}'." - ) + self.io.tool_output(f"HEAD is: {current_head_hash} {current_head_message}") if self.coder.main_model.send_undo_reply: return prompts.undo_command_reply @@ -375,8 +371,8 @@ class Commands: diff = self.coder.repo.diff_commits( self.coder.pretty, - 'HEAD^', - 'HEAD', + "HEAD^", + "HEAD", ) # don't use io.tool_output() because we don't want to log or further colorize