mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
aider: Added condition to check if the last commit's hash matches last_aider_commit_hash
before undoing the commit.
# Context: USER: also double check the last commit against last_aider_commit_hash ASSISTANT: To double-check the last commit against `last_aider_commit_hash` before undoing the commit, you can add a condition to the `cmd_undo` method in the `Coder` class in `aider/coder.py`. ```python aider/coder.py <<<<<<< ORIGINAL last_commit = self.repo.head.commit if not last_commit.message.startswith("aider:"): self.console.print("[red]The last commit was not made by Aider.") return ======= last_commit = self.repo.head.commit if not last_commit.message.startswith("aider:") or last_commit.hexsha[:7] != self.last_aider_commit_hash: self.console.print("[red]The last commit was not made by Aider or the commit hash does not match.") return >>>>>>> UPDATED ``` This change adds a condition to check if the last commit's hash matches `last_aider_commit_hash` before undoing the commit. If it doesn't match, the method will print a message and return without undoing the commit.
This commit is contained in:
parent
59ab516cbb
commit
cfd27c84e9
1 changed files with 2 additions and 3 deletions
|
@ -493,10 +493,9 @@ class Coder:
|
|||
return
|
||||
|
||||
last_commit = self.repo.head.commit
|
||||
if not last_commit.message.startswith("aider:"):
|
||||
self.console.print("[red]The last commit was not made by Aider.")
|
||||
if not last_commit.message.startswith("aider:") or last_commit.hexsha[:7] != self.last_aider_commit_hash:
|
||||
self.console.print("[red]The last commit was not made by Aider or the commit hash does not match.")
|
||||
return
|
||||
|
||||
self.repo.git.reset("--hard", "HEAD~1")
|
||||
self.console.print(f"[red]Undid the last commit: {last_commit.message.strip()}")
|
||||
def cmd_add(self, args):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue