Skip to content

Preserve gitignore negation order#591

Open
CodingFeng101 wants to merge 1 commit into
coderamp-labs:mainfrom
CodingFeng101:codex/preserve-gitignore-negation-order
Open

Preserve gitignore negation order#591
CodingFeng101 wants to merge 1 commit into
coderamp-labs:mainfrom
CodingFeng101:codex/preserve-gitignore-negation-order

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

load_ignore_patterns() now preserves ignore-file order instead of collecting rules in a set, and _apply_gitignores() appends those ordered rules to the query's ignore patterns.

Why

Gitignore negation rules are order-dependent. A common pattern such as:

*.log
!important.log

must allow important.log back in after the broader *.log rule. Collecting those rules in a set makes the behavior depend on Python hash ordering, so the negation can be evaluated before the ignore rule and then get overwritten.

Validation

  • python -m pytest tests\\test_gitignore_feature.py -q
  • python -m ruff check src\\gitingest\\entrypoint.py src\\gitingest\\utils\\ignore_patterns.py src\\gitingest\\utils\\ingestion_utils.py tests\\test_gitignore_feature.py

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.

1 participant