2727 from types import TracebackType
2828
2929 from gitingest .schemas import IngestionQuery
30+ from gitingest .schemas import Context
3031
3132
3233async def ingest_async (
@@ -48,6 +49,8 @@ async def ingest_async(
4849 and processes its files according to the specified query parameters. It returns a summary, a tree-like
4950 structure of the files, and the content of the files. The results can optionally be written to an output file.
5051
52+ The output is generated lazily using a Context object and its .generate_digest() method.
53+
5154 Parameters
5255 ----------
5356 source : str
@@ -112,7 +115,8 @@ async def ingest_async(
112115 async with _clone_repo_if_remote (query , token = token ):
113116 if not include_gitignored :
114117 _apply_gitignores (query )
115- summary , tree , content = ingest_query (query )
118+ context = ingest_query (query )
119+ summary , tree , content = context .generate_digest ()
116120 await _write_output (tree , content = content , target = output )
117121 return summary , tree , content
118122
@@ -136,6 +140,8 @@ def ingest(
136140 and processes its files according to the specified query parameters. It returns a summary, a tree-like
137141 structure of the files, and the content of the files. The results can optionally be written to an output file.
138142
143+ The output is generated lazily using a Context object and its .generate_digest() method.
144+
139145 Parameters
140146 ----------
141147 source : str
@@ -175,20 +181,20 @@ def ingest(
175181 ``ingest_async`` : The asynchronous version of this function.
176182
177183 """
178- return asyncio . run (
179- ingest_async (
180- source = source ,
181- max_file_size = max_file_size ,
182- include_patterns = include_patterns ,
183- exclude_patterns = exclude_patterns ,
184- branch = branch ,
185- tag = tag ,
186- include_gitignored = include_gitignored ,
187- include_submodules = include_submodules ,
188- token = token ,
189- output = output ,
190- ),
191- )
184+ import asyncio
185+ context = asyncio . run ( ingest_async (
186+ source ,
187+ max_file_size = max_file_size ,
188+ include_patterns = include_patterns ,
189+ exclude_patterns = exclude_patterns ,
190+ branch = branch ,
191+ tag = tag ,
192+ include_gitignored = include_gitignored ,
193+ include_submodules = include_submodules ,
194+ token = token ,
195+ output = output ,
196+ ))
197+ return context . generate_digest ( )
192198
193199
194200def _override_branch_and_tag (query : IngestionQuery , branch : str | None , tag : str | None ) -> None :
0 commit comments