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):
|
def apply_updates(self):
|
||||||
try:
|
try:
|
||||||
edited = self.update_files()
|
edited = self.update_files()
|
||||||
return edited, None
|
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
err = err.args[0]
|
err = err.args[0]
|
||||||
self.io.tool_error("Malformed response, retrying...")
|
self.io.tool_error("Malformed response, retrying...")
|
||||||
|
@ -733,6 +732,11 @@ class Coder:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return None, err
|
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):
|
def parse_partial_args(self):
|
||||||
# dump(self.partial_response_function_call)
|
# dump(self.partial_response_function_call)
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,8 @@ class EditBlockCoder(Coder):
|
||||||
):
|
):
|
||||||
self.repo.git.add(full_path)
|
self.repo.git.add(full_path)
|
||||||
|
|
||||||
edited.add(path)
|
|
||||||
if do_replace(full_path, original, updated, self.dry_run):
|
if do_replace(full_path, original, updated, self.dry_run):
|
||||||
if self.dry_run:
|
edited.add(path)
|
||||||
self.io.tool_output(f"Dry run, did not apply edit to {path}")
|
|
||||||
else:
|
|
||||||
self.io.tool_output(f"Applied edit to {path}")
|
|
||||||
else:
|
else:
|
||||||
self.io.tool_error(f"Failed to apply edit to {path}")
|
self.io.tool_error(f"Failed to apply edit to {path}")
|
||||||
|
|
||||||
|
|
|
@ -111,18 +111,24 @@ class FunctionCoder(Coder):
|
||||||
|
|
||||||
files = args.get("files", [])
|
files = args.get("files", [])
|
||||||
|
|
||||||
|
chat_files = self.get_inchat_relative_files()
|
||||||
|
|
||||||
edited = set()
|
edited = set()
|
||||||
for file_upd in files:
|
for file_upd in files:
|
||||||
path = file_upd.get("path")
|
path = file_upd.get("path")
|
||||||
if not path:
|
if not path:
|
||||||
raise ValueError(f"Missing path: {file_upd}")
|
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")
|
content = file_upd.get("content")
|
||||||
if not content:
|
if not content:
|
||||||
raise ValueError(f"Missing content: {file_upd}")
|
raise ValueError(f"Missing content: {file_upd}")
|
||||||
|
|
||||||
full_path = os.path.abspath(os.path.join(self.root, path))
|
|
||||||
Path(full_path).write_text(content)
|
|
||||||
edited.add(path)
|
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)
|
||||||
|
|
||||||
return edited
|
return edited
|
||||||
|
|
|
@ -54,9 +54,10 @@ class WholeFileCoder(Coder):
|
||||||
).splitlines()
|
).splitlines()
|
||||||
output += show_diff
|
output += show_diff
|
||||||
else:
|
else:
|
||||||
new_lines = "".join(new_lines)
|
|
||||||
Path(full_path).write_text(new_lines)
|
|
||||||
edited.add(fname)
|
edited.add(fname)
|
||||||
|
if not self.dry_run:
|
||||||
|
new_lines = "".join(new_lines)
|
||||||
|
Path(full_path).write_text(new_lines)
|
||||||
|
|
||||||
fname = None
|
fname = None
|
||||||
new_lines = []
|
new_lines = []
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TestCommands(TestCase):
|
||||||
io = InputOutput(pretty=False, yes=True)
|
io = InputOutput(pretty=False, yes=True)
|
||||||
from aider.coders import Coder
|
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)
|
commands = Commands(io, coder)
|
||||||
|
|
||||||
# Call the cmd_add method with 'foo.txt' and 'bar.txt' as a single string
|
# 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