feat: add .git-ai-ignore file support for custom ignore patterns#573
Merged
feat: add .git-ai-ignore file support for custom ignore patterns#573
Conversation
Add support for a .git-ai-ignore file at the repository root that allows users to specify additional file patterns to ignore in git-ai tracking. The file follows .gitignore syntax (one glob pattern per line, # comments, blank lines skipped). Patterns from .git-ai-ignore are unioned with: - Default ignore patterns (lockfiles, generated files, etc.) - Linguist-generated patterns from .gitattributes - User-provided --ignore CLI patterns Works for both regular and bare repositories (reads from HEAD for bare). Includes unit tests for: - Loading patterns from workdir and bare repos - Comment/blank line handling - Deduplication - Missing file handling - Union with gitattributes and user patterns Includes integration tests for: - Checkpoint filtering with .git-ai-ignore - Status diff counting with .git-ai-ignore - Union behavior with .gitattributes linguist-generated Co-Authored-By: unknown <>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Co-Authored-By: unknown <>
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.
feat: add .git-ai-ignore file support for custom ignore patterns
Summary
Adds support for a
.git-ai-ignorefile at the repository root, allowing users to specify additional file patterns to exclude from git-ai tracking. The file uses.gitignore-style syntax (one glob pattern per line,#comments, blank lines skipped).Patterns from
.git-ai-ignoreare unioned with all existing ignore sources ineffective_ignore_patterns():.gitattributeslinguist-generatedpatterns.git-ai-ignorepatterns ← new--ignorepatternsThe implementation mirrors the existing
.gitattributesloading: reads from workdir for normal repos, reads fromHEADfor bare repos.No callers were changed — all four call sites (
checkpoint.rs,status.rs,post_commit.rs,git_ai_handlers.rs) go througheffective_ignore_patterns(), so.git-ai-ignoreis picked up automatically everywhere.Review & Testing Checklist for Human
trim()and skips#-prefixed lines, but does NOT support.gitignorenegation (!pattern), escaped hashes (\#), or directory-only trailing slashes (dir/). Confirm this subset is sufficient for the intended use case..git-ai-ignorepatterns are inserted after.gitattributeslinguist-generated and before extra/user patterns. Verify this doesn't cause unexpected precedence issues given that all patterns are additive (ignore-only, no un-ignore)..git-ai-ignorecontaining a pattern likedocs/**, make changes to files matching that pattern, rungit-ai checkpointandgit-ai status --json, and confirm those files are excluded from stats.Notes
.git-ai-ignorefile is read from the working directory (not the committed version) for non-bare repos, consistent with how.gitattributesis already handled. This means uncommitted.git-ai-ignorefiles take effect immediately.