mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +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
|
return prompts.undo_command_reply
|
||||||
|
|
||||||
def cmd_diff(self, args=""):
|
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:
|
if not self.coder.repo:
|
||||||
self.io.tool_error("No git repository found.")
|
self.io.tool_error("No git repository found.")
|
||||||
return
|
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:
|
if not commit_before_message or commit_before_message == current_head:
|
||||||
self.io.tool_error(f"Last commit {last_commit_hash} was not an aider commit.")
|
self.io.tool_error("No changes to display since the last message.")
|
||||||
self.io.tool_error("You could try `/git diff` or `/git diff HEAD^`.")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
diff = self.coder.repo.diff_commits(
|
diff = self.coder.repo.diff_commits(
|
||||||
self.coder.pretty,
|
self.coder.pretty,
|
||||||
"HEAD^",
|
commit_before_message,
|
||||||
"HEAD",
|
"HEAD",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue