mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
respect --dry-run
This commit is contained in:
parent
08764215c3
commit
5043397848
2 changed files with 18 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue