Never hide a tracked file behind .gitignore; add --no-ignore - #8
Merged
Conversation
git's rule is that an ignore pattern has no effect on a file it already tracks. CodeSnake applied .gitignore to everything a directory walk found, so a pull request could add a file, ignore it, `git add -f` it, and `codesnake check src/` would never see it -- exit 0 with the file in the tree. Reproduced both spellings: an ignored file, and a tracked file inside an ignored directory, where the walk pruned the directory before reaching it. Tracked paths are now exempt from ignore filtering, and a directory holding a tracked file is walked rather than pruned. Untracked ignored files -- build output, generated code -- are still skipped, so the noise the filter exists to suppress is unaffected. The fix needs no flag, so CI written before this release is covered simply by upgrading, and the repository's own self-check no longer needs --no-ignore to be a real gate. The tracked set comes from `git ls-files -z --full-name`, about 2 ms here and run once per walk. Anything going wrong -- no git, not a repository, a timeout -- yields an empty set, which restores the previous behavior rather than silently widening or narrowing the scan. --no-ignore is kept, with its meaning narrowed to what it is now actually for: covering *untracked* ignored files, or a tree that is not a git repository. Extract _load_ignore_state so iter_python_files stays under the complexity and length thresholds the tool enforces on everything else. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0114gUUe4CxYr8W8oC95ffmD
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.
git's rule is that an ignore pattern has no effect on a file it already
tracks. CodeSnake applied .gitignore to everything a directory walk found, so
a pull request could add a file, ignore it,
git add -fit, andcodesnake check src/would never see it -- exit 0 with the file in the tree.Reproduced both spellings: an ignored file, and a tracked file inside an
ignored directory, where the walk pruned the directory before reaching it.
Tracked paths are now exempt from ignore filtering, and a directory holding a
tracked file is walked rather than pruned. Untracked ignored files -- build
output, generated code -- are still skipped, so the noise the filter exists to
suppress is unaffected. The fix needs no flag, so CI written before this
release is covered simply by upgrading, and the repository's own self-check no
longer needs --no-ignore to be a real gate.
The tracked set comes from
git ls-files -z --full-name, about 2 ms here andrun once per walk. Anything going wrong -- no git, not a repository, a timeout
-- yields an empty set, which restores the previous behavior rather than
silently widening or narrowing the scan.
--no-ignore is kept, with its meaning narrowed to what it is now actually for:
covering untracked ignored files, or a tree that is not a git repository.
Extract _load_ignore_state so iter_python_files stays under the complexity and
length thresholds the tool enforces on everything else.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_0114gUUe4CxYr8W8oC95ffmD