Skip to content

Place repository root level readme first in file content output #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/gitingest/ingest_from_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,21 @@ def create_file_content_string(files: List[Dict]) -> str:
output = ""
separator = "=" * 48 + "\n"

# First add README.md if it exists
for file in files:
if not file['content']:
continue
if file['path'].lower() == '/readme.md':
output += separator
output += f"File: {file['path']}\n"
output += separator
output += f"{file['content']}\n\n"
break

# Then add all other files in their original order
for file in files:
if not file['content'] or file['path'].lower() == '/readme.md':
continue
output += separator
output += f"File: {file['path']}\n"
output += separator
Expand Down
Loading