1111from gitingest .config import TMP_BASE_PATH
1212from gitingest .ingestion import ingest_query
1313from gitingest .query_parsing import IngestionQuery , parse_query
14+ from gitingest .utils .ignore_patterns import load_gitignore_patterns
1415
1516
1617async def ingest_async (
@@ -19,6 +20,7 @@ async def ingest_async(
1920 include_patterns : Optional [Union [str , Set [str ]]] = None ,
2021 exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
2122 branch : Optional [str ] = None ,
23+ include_gitignored : bool = False ,
2224 token : Optional [str ] = None ,
2325 include_submodules : bool = False ,
2426 output : Optional [str ] = None ,
@@ -46,6 +48,8 @@ async def ingest_async(
4648 include_submodules : bool
4749 If True, recursively include and analyze all Git submodules within the repository.
4850 Set to False to ignore submodules during analysis (default is False).
51+ include_gitignored : bool
52+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
4953 token : str, optional
5054 GitHub personal-access token (PAT). Needed when *source* refers to a
5155 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -81,6 +85,10 @@ async def ingest_async(
8185 token = token ,
8286 )
8387
88+ if not include_gitignored :
89+ gitignore_patterns = load_gitignore_patterns (query .local_path )
90+ query .ignore_patterns .update (gitignore_patterns )
91+
8492 if query .url :
8593 selected_branch = branch if branch else query .branch # prioritize branch argument
8694 query .branch = selected_branch
@@ -123,6 +131,7 @@ def ingest(
123131 exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
124132 branch : Optional [str ] = None ,
125133 include_submodules : bool = False ,
134+ include_gitignored : bool = False ,
126135 token : Optional [str ] = None ,
127136 output : Optional [str ] = None ,
128137) -> Tuple [str , str , str ]:
@@ -149,6 +158,8 @@ def ingest(
149158 include_submodules : bool
150159 If True, recursively include and analyze all Git submodules within the repository.
151160 Set to False to ignore submodules during analysis (default is False).
161+ include_gitignored : bool
162+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
152163 token : str, optional
153164 GitHub personal-access token (PAT). Needed when *source* refers to a
154165 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -175,6 +186,7 @@ def ingest(
175186 exclude_patterns = exclude_patterns ,
176187 branch = branch ,
177188 include_submodules = include_submodules ,
189+ include_gitignored = include_gitignored ,
178190 token = token ,
179191 output = output ,
180192 )
0 commit comments