feat: add ignore patterns support for stats command#462
Open
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
Open
feat: add ignore patterns support for stats command#462txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
Conversation
Add support for ignoring file patterns in stats calculations, with three configuration levels: 1. CLI flag: --ignore "*.lock" "*.min.js" 2. Project-level config: .git-ai-ignore in repo root 3. Global config: stats_ignore_patterns in ~/.git-ai/config.json All three levels merge together (additive). Implementation: - Add stats_ignore_patterns field to Config - Add ignore_patterns module to load patterns from files - Merge patterns in handle_stats() before calling stats/range functions - Only affects stats command (not checkpoint, blame, diff) - Uses glob pattern matching (like .gitignore) - Skips entire files from statistics (both AI and human lines) Benefits: - More accurate AI/human code ratio - Exclude noise from lock files and generated code - Team consistency via committed .git-ai-ignore - Flexible: global defaults + per-project overrides
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #461
Summary
This PR implements ignore patterns support for the
statscommand, allowing users to exclude auto-generated files (lock files, minified code, generated code) from AI/human statistics.Implementation
Added three configuration levels (all additive):
1. CLI flag
2. Project-level config
Create
.git-ai-ignorein repository root (gitignore syntax):3. Global config
In
~/.git-ai/config.json:{ "stats_ignore_patterns": [ "*.lock", "*.min.js", "*.generated.*" ] }Changes
src/authorship/ignore_patterns.rsmodule for loading patterns from filesstats_ignore_patternsfield toConfigstructhandle_stats()before calling stats/range functionsstatscommand (not checkpoint, blame, diff)Benefits
✅ More accurate AI/human code ratio
✅ Exclude noise from lock files and generated code
✅ Team consistency via committed
.git-ai-ignore✅ Flexible: global defaults + per-project overrides
Example
Before:
$ git-ai stats HEAD you ████████░░░░░░░░░░░░ ai 65% 35% # Includes 5000 lines from package-lock.jsonAfter:
$ git-ai stats HEAD you ████████████████░░░░ ai 80% 20% # package-lock.json excluded via .git-ai-ignoreTesting
cargo build