fix(detect): honor nested .gitignore/.graphifyignore files below the scan root#1847
Closed
Mohak-Agrawal wants to merge 1 commit into
Closed
fix(detect): honor nested .gitignore/.graphifyignore files below the scan root#1847Mohak-Agrawal wants to merge 1 commit into
Mohak-Agrawal wants to merge 1 commit into
Conversation
…scan root (Graphify-Labs#1206) detect() only read .gitignore/.graphifyignore in the scan root and its ancestor directories (up to the nearest VCS root), loaded once before the walk began. A .gitignore sitting in a descendant directory — e.g. vendor/sub/.gitignore — was never read, so files/dirs it excluded leaked into the graph. Real git (and every other gitignore-aware tool) honors .gitignore at every directory level, not just the ancestor chain. Extracts the per-directory read+parse logic into a shared _load_dir_own_ignore() helper (used by both the existing ancestor-chain loader and the new call site) and invokes it live inside detect()'s os.walk loop for every directory visited, before that directory's children are pruned — so a nested ignore file governs its own subtree with the same closer-file-wins precedence git uses. Adds three regression tests: nested file exclude, nested directory prune (the walk never descends into it), and nested negation overriding a broader root-level rule. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Collaborator
|
Landed on v8 ( |
safishamsi
added a commit
that referenced
this pull request
Jul 13, 2026
Tighten the brittle negation test to use .py files so classification lands in the deterministic `code` bucket (was checking a fuzzy document+unclassified union), and add a composition test asserting a nested `.gitignore` `!` re-include outranks both a root `.gitignore` and `.git/info/exclude` (#1810) — locking the precedence across all three ignore sources. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
safishamsi
added a commit
that referenced
this pull request
Jul 13, 2026
…angelog Adds the regression test the #1855 fix was missing: _rebuild_code must produce graph.json whose clustered nodes carry community_name, guarding against the label-stripping regression recurring. Also records #1847 and #1855 in the 0.9.15 changelog. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Closes #1206.
detect()only read.gitignore/.graphifyignorefiles in the scan root and its ancestor directories (up to the nearest VCS root), loaded once before the walk began. A.gitignoresitting in a descendant directory — e.g.vendor/sub/.gitignore— was never read at all, so files/dirs it was meant to exclude leaked into the graph. Realgit(and every other gitignore-aware tool) honors.gitignoreat every directory level, not just the ancestor chain._load_graphifyignore's ancestor loop) into a shared_load_dir_own_ignore()helper — no behavior change to the existing ancestor-chain path.detect()'sos.walkloop now calls_load_dir_own_ignore(dp)for every directory it visits (except the scan root, already covered), appending patterns before that directory's children are pruned — so a nested ignore file governs its own subtree with git's usual closer-file-wins precedence.Test plan
tests/test_detect.py: nested file exclude, nested directory prune (walk never descends into it), nested!negation overriding a broader root-level rule.graphifyignore/ancestor-chain tests re-verified — no regressionspytestinstalled) — all pass; would appreciate a CI run to confirm under the project's actual test runner🤖 Generated with Claude Code