mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Added check to ensure the repo isn't dirty before undoing.
# Context: USER: in /undo make sure the repo isn't dirty before undoing ASSISTANT: To ensure the repo isn't dirty before undoing, we will add a check using `self.coder.repo.is_dirty()` before performing the undo operation. ```python aider/commands.py <<<<<<< ORIGINAL def cmd_undo(self, args): "Undo the last git commit if it was done by aider" if not self.coder.repo: self.io.tool_error("No git repository found.") return last_commit = self.coder.repo.head.commit ======= def cmd_undo(self, args): "Undo the last git commit if it was done by aider" if not self.coder.repo: self.io.tool_error("No git repository found.") return if self.coder.repo.is_dirty(): self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.") return last_commit = self.coder.repo.head.commit >>>>>>> UPDATED ```
This commit is contained in:
parent
981710ca16
commit
2b6ea21a0b
1 changed files with 4 additions and 0 deletions
|
@ -85,6 +85,10 @@ class Commands:
|
||||||
self.io.tool_error("No git repository found.")
|
self.io.tool_error("No git repository found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.coder.repo.is_dirty():
|
||||||
|
self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
|
||||||
|
return
|
||||||
|
|
||||||
last_commit = self.coder.repo.head.commit
|
last_commit = self.coder.repo.head.commit
|
||||||
if (
|
if (
|
||||||
not last_commit.message.startswith("aider:")
|
not last_commit.message.startswith("aider:")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue