Skip to content

Commit

Permalink
refactor: add dry run mode to apply_edits method
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gauthier committed Oct 29, 2024
1 parent 3ccae4e commit 28d9f6f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions aider/coders/editblock_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ def get_edits(self):

return edits

def apply_edits(self, edits):
def apply_edits_dry_run(self, edits):
return self.apply_edits(edits, dry_run=True)

def apply_edits(self, edits, dry_run=False):
failed = []
passed = []
updated = []

for edit in edits:
path, original, updated = edit
Expand All @@ -52,14 +56,21 @@ def apply_edits(self, edits):
if new_content:
break

# ai: update full_path->path!
updated.append((path, original, updated))

if new_content:
self.io.write_text(full_path, new_content)
if not dry_run:
self.io.write_text(full_path, new_content)
passed.append(edit)
else:
failed.append(edit)

if dry_run:
return updated

if not failed:
return passed
return

blocks = "block" if len(failed) == 1 else "blocks"

Expand Down

0 comments on commit 28d9f6f

Please sign in to comment.