fix: respect include patterns for directory symlinks#593
Open
Phoenix0531-sudo wants to merge 1 commit into
Open
fix: respect include patterns for directory symlinks#593Phoenix0531-sudo wants to merge 1 commit into
Phoenix0531-sudo wants to merge 1 commit into
Conversation
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
Fix a bug where directory symlinks bypass include-pattern filtering.
When a symlink points to a directory,
Path.is_dir()follows the link and returnsTrue. The_should_include()directory shortcut therefore accepted such symlinks before checking whether the symlink path matched the user's include patterns.Root cause
src/gitingest/utils/ingestion_utils.pyused this shortcut so normal directories are still traversed while looking for matching descendants:Because
Path.is_dir()follows symlinks, a symlink pointing to a directory was treated like a regular directory and skipped the include-pattern match entirely.Changes
not path.is_symlink()guard to_should_include()'s directory shortcut.Testing
uv run pytest tests/test_ingestion.py::test_include_pattern_excludes_symlink_to_directory -v --tb=short1 passed, 110 warnings in 0.24suv run pytest tests/test_ingestion.py -v --tb=short9 passed, 470 warnings in 0.33suv run pytest tests/ -v --tb=short --ignore=tests/query_parser/test_git_host_agnostic.py140 passed, 63843 warnings in 165.57s (0:02:45)uv run --with ruff ruff check src/gitingest/utils/ingestion_utils.py tests/test_ingestion.pyAll checks passed!Note: a full local
uv run pytest tests/ -v --tb=shortrun does not currently complete in my environment becausetests/query_parser/test_git_host_agnostic.pyhits an external Bitbucket repository that returns403; I therefore ran the rest of the suite with that file ignored.Related issue
Fixes #585