Repository navigation
fix(scanner): exclude patterns honour .gitignore anchors - #206
Merged
Merged
Conversation
A bare exclude name matched at every depth and the anchored forms matched nothing, so excluding a root binary named tool also removed cmd/tool/ from every view and "/tool" or "tool/" changed nothing (#192). matchesPattern now reads a leading "/" as root-anchored and a trailing "/" as directories-only, the way .gitignore does; bare names keep matching at any depth. The walker passes the one fact a path alone lacks, whether it is a directory, so "tool/" prunes the directory and keeps the file. All callers (--exclude, config exclude, watch, topology, MCP) route through this one function. Fixes #192 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
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.
Problem (#192)
excludetoolcmd/tool/main.gogone/tooltool(file or directory)tool/toolat any depth; a file namedtoolis kept/tool/toolChange
One matcher,
scanner/walker.gomatchesPattern, now reads.gitignoreanchors before falling through to the existing extension, component and glob rules. The directory-pruning walk passesisDir=truesotool/can tell a directory from a same-named file. Every exclude consumer (--exclude, configexclude, watch daemon, topology provider, MCP find guidance) already routes throughMatchesFilters→ this function, so one change fixes all of them.Patterns containing
*or?are untouched:/build/*.logis still matched as a plain glob, not anchored. README documents the four forms.Tests
TestMatchesPatterngains 18 cases: the three forms against the issue's fixture (cmd/tool/main.go,lib.go, roottool, roottool/), the directory vs file distinction, andtoolboxas the no-over-match negative.go build ./... && go test ./... && gofmt -l .clean.Not changed: the issue's two follow-ups (
--debugprinting the exclude list and per-pattern removal counts; a warning when an exclude removes files in anonlyextension) are separate work.Fixes #192
🤖 Generated with Claude Code
https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T