11
11
from gitingest .config import TMP_BASE_PATH
12
12
from gitingest .ingestion import ingest_query
13
13
from gitingest .query_parsing import IngestionQuery , parse_query
14
+ from gitingest .utils .ignore_patterns import load_gitignore_patterns
14
15
15
16
16
17
async def ingest_async (
@@ -19,6 +20,7 @@ async def ingest_async(
19
20
include_patterns : Optional [Union [str , Set [str ]]] = None ,
20
21
exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
21
22
branch : Optional [str ] = None ,
23
+ include_gitignored : bool = False ,
22
24
token : Optional [str ] = None ,
23
25
output : Optional [str ] = None ,
24
26
) -> Tuple [str , str , str ]:
@@ -42,6 +44,8 @@ async def ingest_async(
42
44
Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
43
45
branch : str, optional
44
46
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``.
45
49
token : str, optional
46
50
GitHub personal-access token (PAT). Needed when *source* refers to a
47
51
**private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -76,6 +80,10 @@ async def ingest_async(
76
80
token = token ,
77
81
)
78
82
83
+ if not include_gitignored :
84
+ gitignore_patterns = load_gitignore_patterns (query .local_path )
85
+ query .ignore_patterns .update (gitignore_patterns )
86
+
79
87
if query .url :
80
88
selected_branch = branch if branch else query .branch # prioritize branch argument
81
89
query .branch = selected_branch
@@ -117,6 +125,7 @@ def ingest(
117
125
include_patterns : Optional [Union [str , Set [str ]]] = None ,
118
126
exclude_patterns : Optional [Union [str , Set [str ]]] = None ,
119
127
branch : Optional [str ] = None ,
128
+ include_gitignored : bool = False ,
120
129
token : Optional [str ] = None ,
121
130
output : Optional [str ] = None ,
122
131
) -> Tuple [str , str , str ]:
@@ -140,6 +149,8 @@ def ingest(
140
149
Pattern or set of patterns specifying which files to exclude. If `None`, no files are excluded.
141
150
branch : str, optional
142
151
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``.
143
154
token : str, optional
144
155
GitHub personal-access token (PAT). Needed when *source* refers to a
145
156
**private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
@@ -165,6 +176,7 @@ def ingest(
165
176
include_patterns = include_patterns ,
166
177
exclude_patterns = exclude_patterns ,
167
178
branch = branch ,
179
+ include_gitignored = include_gitignored ,
168
180
token = token ,
169
181
output = output ,
170
182
)
0 commit comments