You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,23 @@ gitingest --help
89
89
90
90
This will write the digest in a text file (default `digest.txt`) in your current working directory.
91
91
92
+
### Using Multiple Patterns (CLI)
93
+
94
+
You can specify multiple patterns to include or exclude files and directories by repeating the respective flags (-e for exclude, -i for include). Patterns use standard shell wildcards.
95
+
96
+
```bash
97
+
# Example 1: Exclude all log files, temporary files, and the entire 'dist' directory
Remember that exclusion patterns take precedence. If specific include patterns are provided, only files matching those and not matching any exclude pattern will be processed.
108
+
92
109
## 🐍 Python package usage
93
110
94
111
```python
@@ -111,6 +128,60 @@ import asyncio
111
128
result = asyncio.run(ingest_async("path/to/directory"))
112
129
```
113
130
131
+
### Advanced Pattern Usage (Python API)
132
+
133
+
The Python API allows for fine-grained control by combining include_patterns and exclude_patterns. When both are provided:
134
+
135
+
Files/directories are first checked against all exclusion patterns (default built-in patterns + user-provided exclude_patterns). If a match occurs, the item is skipped.
136
+
137
+
If include_patterns are specified, any remaining item must also match at least one of the include patterns to be kept. If include_patterns is None or empty, this step is skipped.
138
+
139
+
```python
140
+
# Advanced Python API Example
141
+
from gitingest import ingest
142
+
import asyncio
143
+
144
+
# Scenario: Ingest only files within the 'src/' directory of a specific branch,
145
+
# but explicitly exclude any '.log' files found within 'src/'.
146
+
147
+
repo_source ="https://github.com/some/repo"
148
+
target_branch ="develop"
149
+
include_only_src = {"src/*"} # Glob pattern to match items directly inside src/
150
+
exclude_src_logs = {"src/*.log"} # Pattern to exclude log files specifically within src/
151
+
152
+
# --- Synchronous Usage ---
153
+
print("Running synchronous ingest with patterns...")
154
+
summary_sync, tree_sync, content_sync = ingest(
155
+
repo_source,
156
+
branch=target_branch,
157
+
include_patterns=include_only_src,
158
+
exclude_patterns=exclude_src_logs
159
+
# Note: Default ignores like .git/, .venv/ are still active automatically
160
+
)
161
+
162
+
print("\n--- Sync Summary ---")
163
+
print(summary_sync)
164
+
# The resulting tree and content will only contain non-log files
165
+
# directly within the 'src/' directory of the 'develop' branch.
166
+
167
+
# --- Asynchronous Usage ---
168
+
asyncdefrun_async_ingest():
169
+
print("\nRunning asynchronous ingest with patterns...")
This setup ensures that even if src/ contains log files, they will be explicitly removed from the final digest, while only other files directly within src/ are included.
0 commit comments