mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Update changed_files_last_commit
to diff against the prior commit instead of the working directory.
# Aider chat conversation: ASSISTANT: Here is the diff to update the `changed_files_last_commit` to diff against the prior commit: ```diff --- aider/commands.py +++ aider/commands.py @@ ... @@ 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.repo.head.commit - changed_files_last_commit = {item.a_path for item in last_commit.diff(None)} + changed_files_last_commit = {item.a_path for item in last_commit.diff(last_commit.parents[0])} dirty_files = [item.a_path for item in self.coder.repo.repo.index.diff(None)] dirty_files_in_last_commit = changed_files_last_commit.intersection(dirty_files) dump(changed_files_last_commit) dump(dirty_files) dump(dirty_files_in_last_commit) if dirty_files_in_last_commit: self.io.tool_error( "The repository has uncommitted changes in files that were modified in the last commit. " "Please commit or stash them before undoing." ) return @@ ... @@ ``` This change will ensure that `changed_files_last_commit` contains the files that were changed in the last commit by comparing it to its parent commit, rather than comparing it to the working directory.
This commit is contained in:
parent
34c4331110
commit
695299be3d
1 changed files with 1 additions and 1 deletions
|
@ -188,7 +188,7 @@ class Commands:
|
|||
|
||||
last_commit = self.coder.repo.repo.head.commit
|
||||
dump(last_commit)
|
||||
changed_files_last_commit = {item.a_path for item in last_commit.diff(None)}
|
||||
changed_files_last_commit = {item.a_path for item in last_commit.diff(last_commit.parents[0])}
|
||||
dirty_files = [item.a_path for item in self.coder.repo.repo.index.diff(None)]
|
||||
dirty_files_in_last_commit = changed_files_last_commit.intersection(dirty_files)
|
||||
dump(changed_files_last_commit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue