1010from gitingest .cloning import clone_repo
1111from gitingest .ingestion import ingest_query
1212from gitingest .query_parsing import IngestionQuery , parse_query
13+ from gitingest .utils .ignore_patterns import load_gitignore_patterns
1314
1415
1516async def ingest_async (
@@ -18,6 +19,7 @@ async def ingest_async(
1819 include_patterns : Optional [Union [str , Set [str ]]] = None ,
1920 exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
2021 branch : Optional [str ] = None ,
22+ include_gitignored : bool = False ,
2123 token : Optional [str ] = None ,
2224 output : Optional [str ] = None ,
2325) -> Tuple [str , str , str ]:
@@ -41,6 +43,8 @@ async def ingest_async(
4143 Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
4244 branch : str, optional
4345 The branch to clone and ingest. If `None`, the default branch is used.
46+ include_gitignored : bool
47+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
4448 token : str, optional
4549 GitHub personal-access token (PAT). Needed when *source* refers to a
4650 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -75,6 +79,10 @@ async def ingest_async(
7579 token = token ,
7680 )
7781
82+ if not include_gitignored :
83+ gitignore_patterns = load_gitignore_patterns (query .local_path )
84+ query .ignore_patterns .update (gitignore_patterns )
85+
7886 if query .url :
7987 selected_branch = branch if branch else query .branch # prioritize branch argument
8088 query .branch = selected_branch
@@ -116,6 +124,7 @@ def ingest(
116124 include_patterns : Optional [Union [str , Set [str ]]] = None ,
117125 exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
118126 branch : Optional [str ] = None ,
127+ include_gitignored : bool = False ,
119128 token : Optional [str ] = None ,
120129 output : Optional [str ] = None ,
121130) -> Tuple [str , str , str ]:
@@ -139,6 +148,8 @@ def ingest(
139148 Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
140149 branch : str, optional
141150 The branch to clone and ingest. If `None`, the default branch is used.
151+ include_gitignored : bool
152+ If ``True``, include files ignored by ``.gitignore``. Defaults to ``False``.
142153 token : str, optional
143154 GitHub personal-access token (PAT). Needed when *source* refers to a
144155 **private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -164,6 +175,7 @@ def ingest(
164175 include_patterns = include_patterns ,
165176 exclude_patterns = exclude_patterns ,
166177 branch = branch ,
178+ include_gitignored = include_gitignored ,
167179 token = token ,
168180 output = output ,
169181 )
0 commit comments