[PR #573] feat: add .git-ai-ignore file support for custom ignore patterns #578

Closed
opened 2026-03-02 04:14:01 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/573

State: closed
Merged: Yes


feat: add .git-ai-ignore file support for custom ignore patterns

Summary

Adds support for a .git-ai-ignore file 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-ignore are unioned with all existing ignore sources in effective_ignore_patterns():

  1. Built-in defaults (lockfiles, generated files, etc.)
  2. .gitattributes linguist-generated patterns
  3. .git-ai-ignore patterns ← new
  4. Extra patterns (programmatic)
  5. User CLI --ignore patterns

The implementation mirrors the existing .gitattributes loading: reads from workdir for normal repos, reads from HEAD for bare repos.

No callers were changed — all four call sites (checkpoint.rs, status.rs, post_commit.rs, git_ai_handlers.rs) go through effective_ignore_patterns(), so .git-ai-ignore is picked up automatically everywhere.

Review & Testing Checklist for Human

  • Verify the simplified parsing is acceptable: The parser strips leading/trailing whitespace via trim() and skips #-prefixed lines, but does NOT support .gitignore negation (!pattern), escaped hashes (\#), or directory-only trailing slashes (dir/). Confirm this subset is sufficient for the intended use case.
  • Confirm union ordering is correct: .git-ai-ignore patterns are inserted after .gitattributes linguist-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).
  • Test manually: Create a repo with a .git-ai-ignore containing a pattern like docs/**, make changes to files matching that pattern, run git-ai checkpoint and git-ai status --json, and confirm those files are excluded from stats.

Notes

  • The .git-ai-ignore file is read from the working directory (not the committed version) for non-bare repos, consistent with how .gitattributes is already handled. This means uncommitted .git-ai-ignore files take effect immediately.
  • All 19 unit tests and 8 integration tests pass locally.
  • Link to Devin run
  • Requested by: @svarlamov

Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/573 **State:** closed **Merged:** Yes --- # feat: add .git-ai-ignore file support for custom ignore patterns ## Summary Adds support for a `.git-ai-ignore` file 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-ignore` are **unioned** with all existing ignore sources in `effective_ignore_patterns()`: 1. Built-in defaults (lockfiles, generated files, etc.) 2. `.gitattributes` `linguist-generated` patterns 3. **`.git-ai-ignore` patterns** ← new 4. Extra patterns (programmatic) 5. User CLI `--ignore` patterns The implementation mirrors the existing `.gitattributes` loading: reads from workdir for normal repos, reads from `HEAD` for bare repos. **No callers were changed** — all four call sites (`checkpoint.rs`, `status.rs`, `post_commit.rs`, `git_ai_handlers.rs`) go through `effective_ignore_patterns()`, so `.git-ai-ignore` is picked up automatically everywhere. ## Review & Testing Checklist for Human - [ ] **Verify the simplified parsing is acceptable**: The parser strips leading/trailing whitespace via `trim()` and skips `#`-prefixed lines, but does NOT support `.gitignore` negation (`!pattern`), escaped hashes (`\#`), or directory-only trailing slashes (`dir/`). Confirm this subset is sufficient for the intended use case. - [ ] **Confirm union ordering is correct**: `.git-ai-ignore` patterns are inserted after `.gitattributes` linguist-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). - [ ] **Test manually**: Create a repo with a `.git-ai-ignore` containing a pattern like `docs/**`, make changes to files matching that pattern, run `git-ai checkpoint` and `git-ai status --json`, and confirm those files are excluded from stats. ### Notes - The `.git-ai-ignore` file is read from the **working directory** (not the committed version) for non-bare repos, consistent with how `.gitattributes` is already handled. This means uncommitted `.git-ai-ignore` files take effect immediately. - All 19 unit tests and 8 integration tests pass locally. - [Link to Devin run](https://app.devin.ai/sessions/cec3cc021fb843dc930bc6e4f39ae61c) - Requested by: @svarlamov <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/573" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
kerem 2026-03-02 04:14:01 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#578
No description provided.