respect --dry-run

This commit is contained in:
Paul Gauthier 2023-06-22 11:38:39 -07:00
parent 08764215c3
commit 5043397848
2 changed files with 18 additions and 16 deletions

View file

@ -1,5 +1,4 @@
import os
from pathlib import Path
from aider import diffs
@ -111,24 +110,17 @@ class WholeFileFunctionCoder(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.")
raise ValueError(f"Missing path parameter: {file_upd}")
content = file_upd.get("content")
if not content:
raise ValueError(f"Missing content: {file_upd}")
raise ValueError(f"Missing content parameter: {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)
if self.allowed_to_edit(path, content):
edited.add(path)
return edited