2727 from types import TracebackType
2828
2929 from gitingest .schemas import IngestionQuery
30+ from gitingest .schemas import Context
3031
3132# Initialize logger for this module
3233logger = get_logger (__name__ )
@@ -51,6 +52,8 @@ async def ingest_async(
5152 and processes its files according to the specified query parameters. It returns a summary, a tree-like
5253 structure of the files, and the content of the files. The results can optionally be written to an output file.
5354
55+ The output is generated lazily using a Context object and its .generate_digest() method.
56+
5457 Parameters
5558 ----------
5659 source : str
@@ -142,6 +145,8 @@ async def ingest_async(
142145
143146 if output :
144147 logger .debug ("Writing output to file" , extra = {"output_path" : output })
148+ context = ingest_query (query )
149+ summary , tree , content = context .generate_digest ()
145150 await _write_output (tree , content = content , target = output )
146151
147152 logger .info ("Ingestion completed successfully" )
@@ -167,6 +172,8 @@ def ingest(
167172 and processes its files according to the specified query parameters. It returns a summary, a tree-like
168173 structure of the files, and the content of the files. The results can optionally be written to an output file.
169174
175+ The output is generated lazily using a Context object and its .generate_digest() method.
176+
170177 Parameters
171178 ----------
172179 source : str
@@ -206,20 +213,20 @@ def ingest(
206213 ``ingest_async`` : The asynchronous version of this function.
207214
208215 """
209- return asyncio . run (
210- ingest_async (
211- source = source ,
212- max_file_size = max_file_size ,
213- include_patterns = include_patterns ,
214- exclude_patterns = exclude_patterns ,
215- branch = branch ,
216- tag = tag ,
217- include_gitignored = include_gitignored ,
218- include_submodules = include_submodules ,
219- token = token ,
220- output = output ,
221- ),
222- )
216+ import asyncio
217+ context = asyncio . run ( ingest_async (
218+ source ,
219+ max_file_size = max_file_size ,
220+ include_patterns = include_patterns ,
221+ exclude_patterns = exclude_patterns ,
222+ branch = branch ,
223+ tag = tag ,
224+ include_gitignored = include_gitignored ,
225+ include_submodules = include_submodules ,
226+ token = token ,
227+ output = output ,
228+ ))
229+ return context . generate_digest ( )
223230
224231
225232def _override_branch_and_tag (query : IngestionQuery , branch : str | None , tag : str | None ) -> None :
0 commit comments