Repository navigation
fix(watch): stop re-reading the ignore rules on a read of their files - #3584
Conversation
The watcher re-read `.gitignore`, `.cgrignore` and the git index on any event naming them, reads included. Re-reading them opens those same files, so on Linux each reload raised the `opened` and `closed_no_write` events of the next: one `git status` (VS Code's Source Control panel runs them) set off a loop that re-read `.gitignore` every few milliseconds, for good. Only a write, creation, deletion or rename of an input re-reads the rules now. Edits to the ignore files and `git add`/`git mv` still apply as before. Fixes #3583
Tested 1 flow, found no issues. What we tested
Took 2 attempts. TREX adjusted its test setup between them. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
[Low impact] The PR appears safe to merge. SummaryStops read-only events from reloading the ignore rules in
Reviews (1) · Last reviewed commit: "fix(watch): stop re-reading the ignore r..." · Reviewed by Greptile |
|



Summary
cgr watchre-read its ignore rules on any event naming.gitignore,.cgrignoreor the git index, reads included. Re-reading them opens those same files, so on Linux each reload raised theopened/closed_no_writeevents of the next one. A singlegit status(VS Code's Source Control panel runs them) started a loop that re-read.gitignoreevery few milliseconds, forever, flooding the log withLoaded N exclude and 0 unignore patterns.RULE_INPUT_EVENT_TYPES). Editing an ignore file,git add,git mvandgit rmstill apply exactly as before.Demo
Terminal output of a reproduction script that runs the real watchdog observer and real
IgnoreRuleson a temporary git repo, counting reads of.gitignoreover 2 seconds (no VHS recording available in this environment):Before (
main):After (this branch):
The 2 remaining reads are the expected single reload after
git statusactually rewrote the index.Type of Change
Related Issues
Fixes #3583
Test Plan
make test-paralleloruv run pytest -n auto -m "not integration") — ran the watcher suites only (212 passed, 25 skipped), not the full suitecodebase_rag/tests/test_watcher_ignore_rule_reads.py: reads of each input leave the rules alone; writes, creations, deletions, closes-after-write and theindex.lock→indexrename still reload them; and an end-to-end test on the real inotify observer shows one read of.gitignoresets off no reloads. 7 of these fail onmain.make test-integration, requires Docker)Checklist
!in the title and its release notes inchanges/breaking/<PR number>.md(not a breaking change)make pre-commit) — all pass exceptty check, which fails locally only on unresolved imports of optional extras in untouched files; no new diagnostics# type: ignore,cast(),Any, orobjecttype hintsSummary by CodeRabbit