Merge pull request 'truncate diff if longer than 60k' (#111) from feature/trunc-diff into main
All checks were successful
Check flake.lock / Check health of `flake.lock` (push) Successful in 41s
Check Nix formatting / Perform Nix format checks (push) Successful in 3m19s
Check Nix flake / Perform Nix flake checks (push) Successful in 5m58s
Update flakes / update_lockfile (push) Successful in 11m49s

Reviewed-on: #111
This commit is contained in:
ahuston-0 2025-05-27 11:21:34 -04:00
commit fbe2ccf445

View File

@ -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)