fix: Ensure .txt extension for flattened filenames and chunk filenames during export

This commit is contained in:
Lutz Leonhardt 2025-03-09 01:16:30 +01:00
parent c9f3c1722a
commit b9d0a24810
2 changed files with 8 additions and 4 deletions

1
.gitignore vendored
View file

@ -16,4 +16,3 @@ aider/_version.py
.#* .#*
.gitattributes .gitattributes
tmp.benchmarks/ tmp.benchmarks/
.qodo

View file

@ -1506,8 +1506,10 @@ Just show me the edits I need to make.
self.io.tool_warning(f"Could not read {rel_fname}, skipping") self.io.tool_warning(f"Could not read {rel_fname}, skipping")
continue continue
# Flatten filename # Flatten filename and ensure .txt extension
flat_fname = rel_fname.replace('/', '|').replace('\\', '|') flat_fname = rel_fname.replace('/', '|').replace('\\', '|')
if not flat_fname.endswith('.txt'):
flat_fname += '.txt'
out_path = os.path.join(export_dir, flat_fname) out_path = os.path.join(export_dir, flat_fname)
# Write content # Write content
@ -1565,14 +1567,17 @@ Just show me the edits I need to make.
# Create chunk filename - different format if only one file in the chunk # Create chunk filename - different format if only one file in the chunk
if len(chunk) == 1: if len(chunk) == 1:
# Just use the single filename for single-file chunks # Just use the single filename for single-file chunks
chunk_fname = f"{chunk[0][0]}_chunk_{i}.txt" chunk_fname = f"{chunk[0][0]}_chunk_{i}"
else: else:
# Get first and last file in chunk for multi-file chunks # Get first and last file in chunk for multi-file chunks
first_file = chunk[0][0] first_file = chunk[0][0]
last_file = chunk[-1][0] last_file = chunk[-1][0]
chunk_fname = f"{first_file}...{last_file}_chunk_{i}.txt" chunk_fname = f"{first_file}...{last_file}_chunk_{i}"
# Replace path separators with pipe characters for better readability # Replace path separators with pipe characters for better readability
chunk_fname = chunk_fname.replace('/', '|').replace('\\', '|') chunk_fname = chunk_fname.replace('/', '|').replace('\\', '|')
# Ensure .txt extension
if not chunk_fname.endswith('.txt'):
chunk_fname += '.txt'
out_path = os.path.join(export_dir, chunk_fname) out_path = os.path.join(export_dir, chunk_fname)
# Write content with file markers # Write content with file markers