mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
fixed test
This commit is contained in:
parent
e26acbae65
commit
4b69e2b85c
5 changed files with 18 additions and 11 deletions
|
@ -720,7 +720,6 @@ class Coder:
|
|||
def apply_updates(self):
|
||||
try:
|
||||
edited = self.update_files()
|
||||
return edited, None
|
||||
except ValueError as err:
|
||||
err = err.args[0]
|
||||
self.io.tool_error("Malformed response, retrying...")
|
||||
|
@ -733,6 +732,11 @@ class Coder:
|
|||
traceback.print_exc()
|
||||
return None, err
|
||||
|
||||
if edited:
|
||||
for path in sorted(edited):
|
||||
self.io.tool_output(f"Applied edit to {path}")
|
||||
return edited, None
|
||||
|
||||
def parse_partial_args(self):
|
||||
# dump(self.partial_response_function_call)
|
||||
|
||||
|
|
|
@ -52,12 +52,8 @@ class EditBlockCoder(Coder):
|
|||
):
|
||||
self.repo.git.add(full_path)
|
||||
|
||||
edited.add(path)
|
||||
if do_replace(full_path, original, updated, self.dry_run):
|
||||
if self.dry_run:
|
||||
self.io.tool_output(f"Dry run, did not apply edit to {path}")
|
||||
else:
|
||||
self.io.tool_output(f"Applied edit to {path}")
|
||||
edited.add(path)
|
||||
else:
|
||||
self.io.tool_error(f"Failed to apply edit to {path}")
|
||||
|
||||
|
|
|
@ -111,18 +111,24 @@ class FunctionCoder(Coder):
|
|||
|
||||
files = args.get("files", [])
|
||||
|
||||
chat_files = self.get_inchat_relative_files()
|
||||
|
||||
edited = set()
|
||||
for file_upd in files:
|
||||
path = file_upd.get("path")
|
||||
if not path:
|
||||
raise ValueError(f"Missing path: {file_upd}")
|
||||
|
||||
if path not in chat_files:
|
||||
raise ValueError(f"File {path} not in chat session.")
|
||||
|
||||
content = file_upd.get("content")
|
||||
if not content:
|
||||
raise ValueError(f"Missing content: {file_upd}")
|
||||
|
||||
edited.add(path)
|
||||
if not self.dry_run:
|
||||
full_path = os.path.abspath(os.path.join(self.root, path))
|
||||
Path(full_path).write_text(content)
|
||||
edited.add(path)
|
||||
|
||||
return edited
|
||||
|
|
|
@ -54,9 +54,10 @@ class WholeFileCoder(Coder):
|
|||
).splitlines()
|
||||
output += show_diff
|
||||
else:
|
||||
edited.add(fname)
|
||||
if not self.dry_run:
|
||||
new_lines = "".join(new_lines)
|
||||
Path(full_path).write_text(new_lines)
|
||||
edited.add(fname)
|
||||
|
||||
fname = None
|
||||
new_lines = []
|
||||
|
|
|
@ -23,7 +23,7 @@ class TestCommands(TestCase):
|
|||
io = InputOutput(pretty=False, yes=True)
|
||||
from aider.coders import Coder
|
||||
|
||||
coder = Coder.create(models.GPT35, io, openai_api_key="deadbeef")
|
||||
coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef")
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# Call the cmd_add method with 'foo.txt' and 'bar.txt' as a single string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue