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 output : Optional [str ] = None ,
2426) -> Tuple [str , str , str ]:
@@ -42,6 +44,8 @@ async def ingest_async(
4244 Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
4345 branch : str, optional
4446 The branch to clone and ingest. If `None`, the default branch is used.
47+ include_gitignored : bool
48+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
4549 token : str, optional
4650 GitHub personal-access token (PAT). Needed when *source* refers to a
4751 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -76,6 +80,10 @@ async def ingest_async(
7680 token = token ,
7781 )
7882
83+ if not include_gitignored :
84+ gitignore_patterns = load_gitignore_patterns (query .local_path )
85+ query .ignore_patterns .update (gitignore_patterns )
86+
7987 if query .url :
8088 selected_branch = branch if branch else query .branch # prioritize branch argument
8189 query .branch = selected_branch
@@ -117,6 +125,7 @@ def ingest(
117125 include_patterns : Optional [Union [str , Set [str ]]] = None ,
118126 exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
119127 branch : Optional [str ] = None ,
128+ include_gitignored : bool = False ,
120129 token : Optional [str ] = None ,
121130 output : Optional [str ] = None ,
122131) -> Tuple [str , str , str ]:
@@ -140,6 +149,8 @@ def ingest(
140149 Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
141150 branch : str, optional
142151 The branch to clone and ingest. If `None`, the default branch is used.
152+ include_gitignored : bool
153+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
143154 token : str, optional
144155 GitHub personal-access token (PAT). Needed when *source* refers to a
145156 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -165,6 +176,7 @@ def ingest(
165176 include_patterns = include_patterns ,
166177 exclude_patterns = exclude_patterns ,
167178 branch = branch ,
179+ include_gitignored = include_gitignored ,
168180 token = token ,
169181 output = output ,
170182 )
0 commit comments