Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 83fde0f

Browse files
feat: extract formatter templates to files and rename Context to ContextV1
1 parent 8af2206 commit 83fde0f

File tree

15 files changed

+167
-143
lines changed

15 files changed

+167
-143
lines changed

‎src/gitingest/entrypoint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from types import TracebackType
2929

3030
from gitingest.schemas import IngestionQuery
31-
from gitingest.schemas import Context
31+
from gitingest.schemas import ContextV1
3232

3333
# Initialize logger for this module
3434
logger = get_logger(__name__)
@@ -52,7 +52,7 @@ async def ingest_async(
5252
This function analyzes a source (URL or local path), clones the corresponding repository (if applicable),
5353
and processes its files according to the specified query parameters. It returns a single digest string.
5454
55-
The output is generated lazily using a Context object and the generate_digest() function.
55+
The output is generated lazily using a ContextV1 object and the generate_digest() function.
5656
5757
Parameters
5858
----------
@@ -167,7 +167,7 @@ def ingest(
167167
This function analyzes a source (URL or local path), clones the corresponding repository (if applicable),
168168
and processes its files according to the specified query parameters. It returns a single digest string.
169169
170-
The output is generated lazily using a Context object and the generate_digest() function.
170+
The output is generated lazily using a ContextV1 object and the generate_digest() function.
171171
172172
Parameters
173173
----------
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ SEPARATOR }}
2+
DEBUG: {{ class_name }}
3+
Fields: {{ fields_str }}
4+
{{ SEPARATOR }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Generated using https://gitingest.com/{{ context.query.user_name }}/{{ context.query.repo_name }}
2+
3+
Sources used:
4+
{%- for source in context.sources %}
5+
- {{ source.name }}: {{ source.__class__.__name__ }}
6+
{% endfor %}
7+
8+
{%- for source in context.sources %}
9+
{{ formatter.format(source, context.query) }}
10+
{%- endfor %}
11+
# End of generated content
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{%- if node.depth == 0 %}{{ node.name }}:
2+
{{ node.tree }}
3+
4+
{% endif -%}
5+
{%- for child in node.children -%}
6+
{{ formatter.format(child, query) }}
7+
{%- endfor -%}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ SEPARATOR }}
2+
{{ node.name }}
3+
{{ SEPARATOR }}
4+
{{ node.content }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ SEPARATOR }}
2+
{{ node.name }}{% if node.target %} -> {{ node.target }}{% endif %}
3+
{{ SEPARATOR }}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{%- if node.depth == 0 %}🔗 Git Repository: {{ node.name }}
2+
{{ node.tree }}
3+
4+
{% endif -%}
5+
{%- for child in node.children -%}
6+
{{ formatter.format(child, query) }}
7+
{%- endfor -%}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Repository: {{ context.query.user_name }}/{{ context.query.repo_name }}
2+
Commit: {{ context.query.commit }}
3+
Files analyzed: {{ context.sources[0].file_count }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Directory structure:
2+
{{ node.tree }}

‎src/gitingest/ingestion.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
from gitingest.config import MAX_DIRECTORY_DEPTH, MAX_FILES, MAX_TOTAL_SIZE_BYTES
9-
from gitingest.schemas import Context, FileSystemNode, FileSystemStats
9+
from gitingest.schemas import ContextV1, FileSystemNode, FileSystemStats
1010
from gitingest.schemas.filesystem import FileSystemDirectory, FileSystemFile, FileSystemSymlink, GitRepository
1111
from gitingest.utils.ingestion_utils import _should_exclude, _should_include
1212
from gitingest.utils.logging_config import get_logger
@@ -23,11 +23,11 @@ def _is_git_repository(path: Path) -> bool:
2323
return (path / ".git").exists()
2424

2525

26-
def ingest_query(query: IngestionQuery) -> Context:
26+
def ingest_query(query: IngestionQuery) -> ContextV1:
2727
"""Run the ingestion process for a parsed query.
2828
2929
This is the main entry point for analyzing a codebase directory or single file. It processes the query
30-
parameters, reads the file or directory content, and returns a Context object that can generate the final output digest on demand.
30+
parameters, reads the file or directory content, and returns a ContextV1 object that can generate the final output digest on demand.
3131
3232
Parameters
3333
----------
@@ -36,8 +36,8 @@ def ingest_query(query: IngestionQuery) -> Context:
3636
3737
Returns
3838
-------
39-
Context
40-
A Context object representing the ingested file system nodes. Use generate_digest(context) to get the summary, directory structure, and file contents.
39+
ContextV1
40+
A ContextV1 object representing the ingested file system nodes. Use generate_digest(context) to get the summary, directory structure, and file contents.
4141
4242
Raises
4343
------
@@ -92,7 +92,7 @@ def ingest_query(query: IngestionQuery) -> Context:
9292
"file_size": file_node.size,
9393
},
9494
)
95-
return Context([file_node], query)
95+
return ContextV1([file_node], query)
9696

9797
# Check if this is a git repository and create appropriate node type
9898
if _is_git_repository(path):
@@ -123,7 +123,7 @@ def ingest_query(query: IngestionQuery) -> Context:
123123
},
124124
)
125125

126-
return Context([root_node], query)
126+
return ContextV1([root_node], query)
127127

128128

129129
def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystemStats) -> None:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /