Skip to content

Commit d721b00

Browse files
Replace dict-based query with ParsedQuery dataclass (#133)
- Introduce ParsedQuery dataclass to store query parameters and metadata - Update ingestion and parser modules to use ParsedQuery instead of dict[str, Any] - Convert ignore_patterns and include_patterns to sets - Clean references to max size and pattern handling - Update tests to reflect new dataclass usage
1 parent 3ce8e7e commit d721b00

File tree

12 files changed

+369
-375
lines changed

12 files changed

+369
-375
lines changed

src/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
from pathlib import Path
44

5+
MAX_FILE_SIZE = 10 * 1024 * 1024 # 10 MB
6+
MAX_DIRECTORY_DEPTH = 20 # Maximum depth of directory traversal
7+
MAX_FILES = 10_000 # Maximum number of files to process
8+
MAX_TOTAL_SIZE_BYTES = 500 * 1024 * 1024 # 500 MB
9+
510
MAX_DISPLAY_SIZE: int = 300_000
611
TMP_BASE_PATH = Path("/tmp/gitingest")
712
DELETE_REPO_AFTER: int = 60 * 60 # In seconds

src/gitingest/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import click
66

7-
from gitingest.query_ingestion import MAX_FILE_SIZE
7+
from config import MAX_FILE_SIZE
88
from gitingest.repository_ingest import ingest
99

1010

@@ -49,8 +49,8 @@ async def main(
4949
"""
5050
try:
5151
# Combine default and custom ignore patterns
52-
exclude_patterns = list(exclude_pattern)
53-
include_patterns = list(set(include_pattern))
52+
exclude_patterns = set(exclude_pattern)
53+
include_patterns = set(include_pattern)
5454

5555
if not output:
5656
output = "digest.txt"
@@ -61,7 +61,7 @@ async def main(
6161
click.echo(summary)
6262

6363
except Exception as e:
64-
click.echo(f"Error: {str(e)}", err=True)
64+
click.echo(f"Error: {e}", err=True)
6565
raise click.Abort()
6666

6767

src/gitingest/ignore_patterns.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" Default ignore patterns for Gitingest. """
22

3-
DEFAULT_IGNORE_PATTERNS: list[str] = [
3+
DEFAULT_IGNORE_PATTERNS: set[str] = {
44
# Python
55
"*.pyc",
66
"*.pyo",
@@ -29,18 +29,17 @@
2929
"*.war",
3030
"*.ear",
3131
"*.nar",
32-
"target/",
3332
".gradle/",
3433
"build/",
3534
".settings/",
36-
".project",
3735
".classpath",
3836
"gradle-app.setting",
3937
"*.gradle",
38+
# IDEs and editors / Java
39+
".project",
4040
# C/C++
4141
"*.o",
4242
"*.obj",
43-
"*.so",
4443
"*.dll",
4544
"*.dylib",
4645
"*.exe",
@@ -68,21 +67,22 @@
6867
".ruby-gemset",
6968
".rvmrc",
7069
# Rust
71-
"target/",
7270
"Cargo.lock",
7371
"**/*.rs.bk",
72+
# Java / Rust
73+
"target/",
7474
# Go
75-
"bin/",
7675
"pkg/",
7776
# .NET/C#
78-
"bin/",
7977
"obj/",
8078
"*.suo",
8179
"*.user",
8280
"*.userosscache",
8381
"*.sln.docstates",
8482
"packages/",
8583
"*.nupkg",
84+
# Go / .NET / C#
85+
"bin/",
8686
# Version control
8787
".git",
8888
".svn",
@@ -112,12 +112,9 @@
112112
".idea",
113113
".vscode",
114114
".vs",
115-
"*.swp",
116115
"*.swo",
117116
"*.swn",
118117
".settings",
119-
".project",
120-
".classpath",
121118
"*.sublime-*",
122119
# Temporary and cache files
123120
"*.log",
@@ -140,9 +137,6 @@
140137
"*.egg",
141138
"*.whl",
142139
"*.so",
143-
"*.dylib",
144-
"*.dll",
145-
"*.class",
146140
# Documentation
147141
"site-packages",
148142
".docusaurus",
@@ -159,4 +153,4 @@
159153
"*.tfstate*",
160154
## Dependencies in various languages
161155
"vendor/",
162-
]
156+
}

0 commit comments

Comments
 (0)