From 28d9f6f8daa643175c9b1c92802faa493e665ba8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 29 Oct 2024 14:28:38 -0700 Subject: [PATCH] refactor: add dry run mode to apply_edits method --- aider/coders/editblock_coder.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 462d67b47..551dc8d9a 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -35,9 +35,13 @@ class EditBlockCoder(Coder): 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 @@ -52,14 +56,21 @@ class EditBlockCoder(Coder): 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"