truncate diff if longer than 60k
This commit is contained in:
parent
cf2a168ed5
commit
95620e20cc
@ -12,13 +12,15 @@ def inject_diff():
|
|||||||
out = []
|
out = []
|
||||||
with open(source_file,'r') as src:
|
with open(source_file,'r') as src:
|
||||||
src_content = src.read()
|
src_content = src.read()
|
||||||
|
if len(src_content) > 60000:
|
||||||
|
logging.warning(f"{source_file} is longer than 60k characters, truncating")
|
||||||
|
src_content = src_content[:60000]
|
||||||
with open(target_file,'r') as tgt:
|
with open(target_file,'r') as tgt:
|
||||||
for line in tgt.readlines():
|
for line in tgt.readlines():
|
||||||
if placeholder in line:
|
if placeholder in line:
|
||||||
out.append(line.replace(placeholder,src_content))
|
out.append(line.replace(placeholder,src_content))
|
||||||
else:
|
else:
|
||||||
out.append(line)
|
out.append(line)
|
||||||
logging.info(out)
|
|
||||||
|
|
||||||
with open(target_file,'w') as tgt:
|
with open(target_file,'w') as tgt:
|
||||||
tgt.writelines(out)
|
tgt.writelines(out)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user