mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
simpler
This commit is contained in:
parent
81b1916c6a
commit
d8294cab44
1 changed files with 7 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from aider import diffs
|
from aider import diffs
|
||||||
|
@ -38,11 +37,10 @@ class WholeFileCoder(Coder):
|
||||||
if line.startswith("```"):
|
if line.startswith("```"):
|
||||||
if fname:
|
if fname:
|
||||||
# ending an existing block
|
# ending an existing block
|
||||||
full_path = os.path.abspath(os.path.join(self.root, fname))
|
full_path = (Path(self.root) / fname).absolute()
|
||||||
|
|
||||||
if mode == "diff":
|
if mode == "diff" and full_path.exists():
|
||||||
with open(full_path, "r") as f:
|
orig_lines = full_path.readlines()
|
||||||
orig_lines = f.readlines()
|
|
||||||
|
|
||||||
show_diff = diffs.diff_partial_update(
|
show_diff = diffs.diff_partial_update(
|
||||||
orig_lines,
|
orig_lines,
|
||||||
|
@ -55,7 +53,7 @@ class WholeFileCoder(Coder):
|
||||||
edited.add(fname)
|
edited.add(fname)
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
new_lines = "".join(new_lines)
|
new_lines = "".join(new_lines)
|
||||||
Path(full_path).write_text(new_lines)
|
full_path.write_text(new_lines)
|
||||||
|
|
||||||
fname = None
|
fname = None
|
||||||
new_lines = []
|
new_lines = []
|
||||||
|
@ -78,11 +76,10 @@ class WholeFileCoder(Coder):
|
||||||
if mode == "diff":
|
if mode == "diff":
|
||||||
if fname:
|
if fname:
|
||||||
# ending an existing block
|
# ending an existing block
|
||||||
full_path = os.path.abspath(os.path.join(self.root, fname))
|
full_path = (Path(self.root) / fname).absolute()
|
||||||
|
|
||||||
if mode == "diff":
|
if mode == "diff" and full_path.exists():
|
||||||
with open(full_path, "r") as f:
|
orig_lines = full_path.readlines()
|
||||||
orig_lines = f.readlines()
|
|
||||||
|
|
||||||
show_diff = diffs.diff_partial_update(
|
show_diff = diffs.diff_partial_update(
|
||||||
orig_lines,
|
orig_lines,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue