Skip to content

fix: respect include patterns for directory symlinks#593

Open
Phoenix0531-sudo wants to merge 1 commit into
coderamp-labs:mainfrom
Phoenix0531-sudo:fix/symlink-include-filter
Open

fix: respect include patterns for directory symlinks#593
Phoenix0531-sudo wants to merge 1 commit into
coderamp-labs:mainfrom
Phoenix0531-sudo:fix/symlink-include-filter

Conversation

@Phoenix0531-sudo

Copy link
Copy Markdown

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 returns True. 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.py used this shortcut so normal directories are still traversed while looking for matching descendants:

if path.is_dir():
    return True

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

  • Added a not path.is_symlink() guard to _should_include()'s directory shortcut.
  • Added a regression test covering a directory symlink whose own path does not match the include pattern.

Testing

  • uv run pytest tests/test_ingestion.py::test_include_pattern_excludes_symlink_to_directory -v --tb=short
    • 1 passed, 110 warnings in 0.24s
  • uv run pytest tests/test_ingestion.py -v --tb=short
    • 9 passed, 470 warnings in 0.33s
  • uv run pytest tests/ -v --tb=short --ignore=tests/query_parser/test_git_host_agnostic.py
    • 140 passed, 63843 warnings in 165.57s (0:02:45)
  • uv run --with ruff ruff check src/gitingest/utils/ingestion_utils.py tests/test_ingestion.py
    • All checks passed!

Note: a full local uv run pytest tests/ -v --tb=short run does not currently complete in my environment because tests/query_parser/test_git_host_agnostic.py hits an external Bitbucket repository that returns 403; I therefore ran the rest of the suite with that file ignored.

Related issue

Fixes #585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(bug): include filter not work for SYMLINK

1 participant