mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: Change cmd_diff to show diff since last message
This commit is contained in:
parent
d9e7d64235
commit
543227f6bd
1 changed files with 6 additions and 6 deletions
|
@ -466,21 +466,21 @@ class Commands:
|
|||
return prompts.undo_command_reply
|
||||
|
||||
def cmd_diff(self, args=""):
|
||||
"Display the diff of the last aider commit"
|
||||
"Display the diff of changes since the last message"
|
||||
if not self.coder.repo:
|
||||
self.io.tool_error("No git repository found.")
|
||||
return
|
||||
|
||||
last_commit_hash = self.coder.repo.repo.head.commit.hexsha[:7]
|
||||
current_head = self.coder.repo.repo.head.commit.hexsha
|
||||
commit_before_message = self.coder.commit_before_message
|
||||
|
||||
if last_commit_hash not in self.coder.aider_commit_hashes:
|
||||
self.io.tool_error(f"Last commit {last_commit_hash} was not an aider commit.")
|
||||
self.io.tool_error("You could try `/git diff` or `/git diff HEAD^`.")
|
||||
if not commit_before_message or commit_before_message == current_head:
|
||||
self.io.tool_error("No changes to display since the last message.")
|
||||
return
|
||||
|
||||
diff = self.coder.repo.diff_commits(
|
||||
self.coder.pretty,
|
||||
"HEAD^",
|
||||
commit_before_message,
|
||||
"HEAD",
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue