mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
Merge branch 'main' into help
This commit is contained in:
commit
500cc151a1
5 changed files with 33 additions and 11 deletions
|
@ -1,6 +1,10 @@
|
||||||
|
|
||||||
# Release history
|
# Release history
|
||||||
|
|
||||||
|
### main branch
|
||||||
|
|
||||||
|
- Allow multiple use of `/undo`.
|
||||||
|
|
||||||
### Aider v0.42.0
|
### Aider v0.42.0
|
||||||
|
|
||||||
- Performance release:
|
- Performance release:
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Coder:
|
||||||
abs_fnames = None
|
abs_fnames = None
|
||||||
repo = None
|
repo = None
|
||||||
last_aider_commit_hash = None
|
last_aider_commit_hash = None
|
||||||
|
aider_commit_hashes = set()
|
||||||
aider_edited_files = None
|
aider_edited_files = None
|
||||||
last_asked_for_commit_time = 0
|
last_asked_for_commit_time = 0
|
||||||
repo_map = None
|
repo_map = None
|
||||||
|
@ -117,6 +118,7 @@ class Coder:
|
||||||
fnames=from_coder.get_inchat_relative_files(),
|
fnames=from_coder.get_inchat_relative_files(),
|
||||||
done_messages=done_messages,
|
done_messages=done_messages,
|
||||||
cur_messages=from_coder.cur_messages,
|
cur_messages=from_coder.cur_messages,
|
||||||
|
aider_commit_hashes=from_coder.aider_commit_hashes,
|
||||||
)
|
)
|
||||||
|
|
||||||
use_kwargs.update(update) # override to complete the switch
|
use_kwargs.update(update) # override to complete the switch
|
||||||
|
@ -226,6 +228,7 @@ class Coder:
|
||||||
attribute_author=True,
|
attribute_author=True,
|
||||||
attribute_committer=True,
|
attribute_committer=True,
|
||||||
attribute_commit_message=False,
|
attribute_commit_message=False,
|
||||||
|
aider_commit_hashes=None,
|
||||||
):
|
):
|
||||||
if not fnames:
|
if not fnames:
|
||||||
fnames = []
|
fnames = []
|
||||||
|
@ -233,6 +236,11 @@ class Coder:
|
||||||
if io is None:
|
if io is None:
|
||||||
io = InputOutput()
|
io = InputOutput()
|
||||||
|
|
||||||
|
if aider_commit_hashes:
|
||||||
|
self.aider_commit_hashes = aider_commit_hashes
|
||||||
|
else:
|
||||||
|
self.aider_commit_hashes = set()
|
||||||
|
|
||||||
self.chat_completion_call_hashes = []
|
self.chat_completion_call_hashes = []
|
||||||
self.chat_completion_response_hashes = []
|
self.chat_completion_response_hashes = []
|
||||||
self.need_commit_before_edits = set()
|
self.need_commit_before_edits = set()
|
||||||
|
@ -1454,6 +1462,7 @@ class Coder:
|
||||||
if res:
|
if res:
|
||||||
commit_hash, commit_message = res
|
commit_hash, commit_message = res
|
||||||
self.last_aider_commit_hash = commit_hash
|
self.last_aider_commit_hash = commit_hash
|
||||||
|
self.aider_commit_hashes.add(commit_hash)
|
||||||
self.last_aider_commit_message = commit_message
|
self.last_aider_commit_message = commit_message
|
||||||
if self.show_diffs:
|
if self.show_diffs:
|
||||||
self.commands.cmd_diff()
|
self.commands.cmd_diff()
|
||||||
|
|
|
@ -333,8 +333,9 @@ class Commands:
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
last_commit = self.coder.repo.repo.head.commit
|
last_commit_hash = self.coder.repo.repo.head.commit.hexsha[:7]
|
||||||
if last_commit.hexsha[:7] != self.coder.last_aider_commit_hash:
|
last_commit_message = self.coder.repo.repo.head.commit.message.strip()
|
||||||
|
if last_commit_hash not in self.coder.aider_commit_hashes:
|
||||||
self.io.tool_error("The last commit was not made by aider in this chat session.")
|
self.io.tool_error("The last commit was not made by aider in this chat session.")
|
||||||
self.io.tool_error(
|
self.io.tool_error(
|
||||||
"You could try `/git reset --hard HEAD^` but be aware that this is a destructive"
|
"You could try `/git reset --hard HEAD^` but be aware that this is a destructive"
|
||||||
|
@ -348,9 +349,12 @@ class Commands:
|
||||||
# Move the HEAD back before the latest commit
|
# Move the HEAD back before the latest commit
|
||||||
self.coder.repo.repo.git.reset("--soft", "HEAD~1")
|
self.coder.repo.repo.git.reset("--soft", "HEAD~1")
|
||||||
|
|
||||||
self.io.tool_output(
|
self.io.tool_output(f"Removed: {last_commit_hash} {last_commit_message}")
|
||||||
f"Commit `{self.coder.last_aider_commit_hash}` was reset and removed from git.\n"
|
|
||||||
)
|
# Get the current HEAD after undo
|
||||||
|
current_head_hash = self.coder.repo.repo.head.commit.hexsha[:7]
|
||||||
|
current_head_message = self.coder.repo.repo.head.commit.message.strip()
|
||||||
|
self.io.tool_output(f"HEAD is: {current_head_hash} {current_head_message}")
|
||||||
|
|
||||||
if self.coder.main_model.send_undo_reply:
|
if self.coder.main_model.send_undo_reply:
|
||||||
return prompts.undo_command_reply
|
return prompts.undo_command_reply
|
||||||
|
@ -361,16 +365,17 @@ class Commands:
|
||||||
self.io.tool_error("No git repository found.")
|
self.io.tool_error("No git repository found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.coder.last_aider_commit_hash:
|
last_commit_hash = self.coder.repo.repo.head.commit.hexsha[:7]
|
||||||
self.io.tool_error("No previous aider commit found.")
|
|
||||||
|
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^`.")
|
self.io.tool_error("You could try `/git diff` or `/git diff HEAD^`.")
|
||||||
return
|
return
|
||||||
|
|
||||||
commits = f"{self.coder.last_aider_commit_hash}~1"
|
|
||||||
diff = self.coder.repo.diff_commits(
|
diff = self.coder.repo.diff_commits(
|
||||||
self.coder.pretty,
|
self.coder.pretty,
|
||||||
commits,
|
"HEAD^",
|
||||||
self.coder.last_aider_commit_hash,
|
"HEAD",
|
||||||
)
|
)
|
||||||
|
|
||||||
# don't use io.tool_output() because we don't want to log or further colorize
|
# don't use io.tool_output() because we don't want to log or further colorize
|
||||||
|
|
|
@ -536,7 +536,7 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
# Store the commit hash
|
# Store the commit hash
|
||||||
last_commit_hash = repo.head.commit.hexsha[:7]
|
last_commit_hash = repo.head.commit.hexsha[:7]
|
||||||
coder.last_aider_commit_hash = last_commit_hash
|
coder.aider_commit_hashes.add(last_commit_hash)
|
||||||
|
|
||||||
file_path.write_text("dirty content")
|
file_path.write_text("dirty content")
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@ cog.out(text)
|
||||||
|
|
||||||
# Release history
|
# Release history
|
||||||
|
|
||||||
|
### main branch
|
||||||
|
|
||||||
|
- Allow multiple use of `/undo`.
|
||||||
|
|
||||||
### Aider v0.42.0
|
### Aider v0.42.0
|
||||||
|
|
||||||
- Performance release:
|
- Performance release:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue