mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-02 07:53:41 +08:00
Replace the go-gitignore library's NewRepository (which opens .gitignore files via os.Open but never closes the handles) with a custom repoMatcher that reads files via os.ReadFile and passes strings.NewReader to the library's New() function. This ensures all file handles are closed immediately after reading. The library's ignore.Relative() pattern matching is preserved — only the hierarchy walker and file loading are reimplemented. The matching algorithm follows standard git precedence: child .gitignore overrides parent, negation patterns in child override matching patterns in parent, and .git/info/exclude is checked last. Fixes Windows CI where leaked handles prevented t.TempDir() cleanup.