mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
noop
This commit is contained in:
parent
3897d0a665
commit
7c56dcb16f
1 changed files with 27 additions and 27 deletions
|
@ -35,33 +35,6 @@ class EditBlockCoder(Coder):
|
|||
return edited
|
||||
|
||||
|
||||
def do_replace(fname, content, before_text, after_text, dry_run=False):
|
||||
before_text = strip_quoted_wrapping(before_text, fname)
|
||||
after_text = strip_quoted_wrapping(after_text, fname)
|
||||
fname = Path(fname)
|
||||
|
||||
# does it want to make a new file?
|
||||
if not fname.exists() and not before_text.strip():
|
||||
fname.touch()
|
||||
content = ""
|
||||
|
||||
if content is None:
|
||||
return
|
||||
|
||||
if not before_text.strip():
|
||||
# append to existing file, or start a new file
|
||||
new_content = content + after_text
|
||||
else:
|
||||
new_content = replace_most_similar_chunk(content, before_text, after_text)
|
||||
if not new_content:
|
||||
return
|
||||
|
||||
if not dry_run:
|
||||
fname.write_text(new_content)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def try_dotdotdots(whole, part, replace):
|
||||
"""
|
||||
See if the edit block has ... lines.
|
||||
|
@ -239,6 +212,33 @@ def strip_quoted_wrapping(res, fname=None):
|
|||
return res
|
||||
|
||||
|
||||
def do_replace(fname, content, before_text, after_text, dry_run=False):
|
||||
before_text = strip_quoted_wrapping(before_text, fname)
|
||||
after_text = strip_quoted_wrapping(after_text, fname)
|
||||
fname = Path(fname)
|
||||
|
||||
# does it want to make a new file?
|
||||
if not fname.exists() and not before_text.strip():
|
||||
fname.touch()
|
||||
content = ""
|
||||
|
||||
if content is None:
|
||||
return
|
||||
|
||||
if not before_text.strip():
|
||||
# append to existing file, or start a new file
|
||||
new_content = content + after_text
|
||||
else:
|
||||
new_content = replace_most_similar_chunk(content, before_text, after_text)
|
||||
if not new_content:
|
||||
return
|
||||
|
||||
if not dry_run:
|
||||
fname.write_text(new_content)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
ORIGINAL = "<<<<<<< ORIGINAL"
|
||||
DIVIDER = "======="
|
||||
UPDATED = ">>>>>>> UPDATED"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue