Skip to content

feat: add ignore patterns support for stats command#462

Open
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
txf0096:feat/stats-ignore-patterns
Open

feat: add ignore patterns support for stats command#462
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
txf0096:feat/stats-ignore-patterns

Conversation

@txf0096
Copy link
Contributor

@txf0096 txf0096 commented Feb 5, 2026

Fixes #461

Summary

This PR implements ignore patterns support for the stats command, 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

git-ai stats --ignore "*.lock" "*.min.js" "dist/**"
git-ai stats HEAD --ignore "*.generated.*"

2. Project-level config

Create .git-ai-ignore in repository root (gitignore syntax):

# Lock files
*.lock
go.sum

# Build artifacts  
*.min.js
*.bundle.js

# Generated code
*.generated.*
*_pb.go

3. Global config

In ~/.git-ai/config.json:

{
  "stats_ignore_patterns": [
    "*.lock",
    "*.min.js",
    "*.generated.*"
  ]
}

Changes

  • Add src/authorship/ignore_patterns.rs module for loading patterns from files
  • Add stats_ignore_patterns field to Config struct
  • 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

Example

Before:

$ git-ai stats HEAD
you  ████████░░░░░░░░░░░░ ai
     65%              35%
# Includes 5000 lines from package-lock.json

After:

$ git-ai stats HEAD
you  ████████████████░░░░ ai
     80%              20%  
# package-lock.json excluded via .git-ai-ignore

Testing

  • Compiled successfully with cargo build
  • Pattern loading logic tested with multiple sources
  • Backward compatible (defaults to no patterns if not configured)

Open with Devin

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
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Feature Request: Add ignore patterns support for stats command

1 participant