Skip to content

Commit 0e304a2

Browse files
feat: Add options for large repository handling including commit sampling, max commit limits, and date filtering.
1 parent f1ccdb6 commit 0e304a2

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ You can customize the output by using the following command-line options:
105105
| `--workers` | Number of parallel workers for frame rendering. | CPU count |
106106
| `--compare` | Compare with another branch side-by-side. | None |
107107
| `--show-diff` | Highlight code changes between commits. | `False` |
108+
| `--sample-rate` | Process every Nth commit for large repos. | `1` |
109+
| `--max-commits` | Limit to N most recent commits. | All |
110+
| `--since` | Only include commits after date (YYYY-MM-DD). | None |
111+
| `--until` | Only include commits before date (YYYY-MM-DD). | None |
108112
109113
### Path Filtering Examples
110114
@@ -144,6 +148,7 @@ python -m src.main /path/to/repo output.mp4 --author-colors
144148
145149
## What's New in This Version 🎉
146150

151+
- **Large Repository Handling**: Commit sampling with `--sample-rate` and date filtering
147152
- **Semantic Diffing**: Highlight code changes with `--show-diff`
148153
- **Branch Comparison**: Side-by-side visualization with `--compare BRANCH`
149154
- **Parallel Processing**: Multi-core frame rendering with `--workers`

src/main.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,32 @@ def main():
206206
action="store_true",
207207
help="Highlight code changes between commits (green=added, yellow=modified)."
208208
)
209+
parser.add_argument(
210+
"--sample-rate",
211+
type=int,
212+
default=1,
213+
metavar="N",
214+
help="Process every Nth commit (default: 1 = all commits)."
215+
)
216+
parser.add_argument(
217+
"--max-commits",
218+
type=int,
219+
default=None,
220+
metavar="N",
221+
help="Limit to N most recent commits."
222+
)
223+
parser.add_argument(
224+
"--since",
225+
default=None,
226+
metavar="DATE",
227+
help="Only include commits after this date (YYYY-MM-DD)."
228+
)
229+
parser.add_argument(
230+
"--until",
231+
default=None,
232+
metavar="DATE",
233+
help="Only include commits before this date (YYYY-MM-DD)."
234+
)
209235

210236
args = parser.parse_args()
211237

@@ -261,6 +287,43 @@ def main():
261287
print(f"Skipped {skipped} commits that don't affect filtered paths.")
262288
history = filtered_history
263289

290+
# --- Large repository handling ---
291+
original_count = len(history)
292+
293+
# Date filtering
294+
if args.since or args.until:
295+
from datetime import datetime
296+
filtered = []
297+
for commit in history:
298+
commit_date = commit.get('date')
299+
if commit_date:
300+
if args.since:
301+
since_date = datetime.strptime(args.since, '%Y-%m-%d')
302+
if commit_date.replace(tzinfo=None) < since_date:
303+
continue
304+
if args.until:
305+
until_date = datetime.strptime(args.until, '%Y-%m-%d')
306+
if commit_date.replace(tzinfo=None) > until_date:
307+
continue
308+
filtered.append(commit)
309+
print(f"Date filter ({args.since or 'start'} to {args.until or 'now'}): {len(history)}{len(filtered)} commits")
310+
history = filtered
311+
312+
# Max commits limit
313+
if args.max_commits and len(history) > args.max_commits:
314+
print(f"Limiting to {args.max_commits} most recent commits (from {len(history)})")
315+
history = history[:args.max_commits]
316+
317+
# Commit sampling
318+
if args.sample_rate > 1:
319+
sampled = history[::args.sample_rate]
320+
print(f"Sampling every {args.sample_rate} commits: {len(history)}{len(sampled)} commits")
321+
history = sampled
322+
323+
# Large repo warning
324+
if len(history) > 1000:
325+
print(f"⚠️ Warning: Processing {len(history)} commits. Consider using --sample-rate or --max-commits for faster generation.")
326+
264327
# --- Initialize secret redactor ---
265328
redactor = SecretRedactor(enabled=args.redact_secrets or args.redact_pattern)
266329
if args.redact_pattern:

0 commit comments

Comments
 (0)