fix(core): honor escaped hashes and whitespace in ignore patterns - #1544
Conversation
.bmignore documents gitignore-style syntax, but the loader skipped any line beginning with '#' and never unescaped a leading backslash, so no pattern beginning with a hash could take effect: '#*#' was dropped as a comment and '\#*#' was stored literally and never matched. Strip one leading backslash when a line starts with '\#', for both .bmignore and project .gitignore, so e.g. '\#*#' loads as '#*#' (Emacs autosave files). Fixes #1539 Signed-off-by: wangzhengzhuo05 <[email protected]>
Signed-off-by: phernandez <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee2f8545bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Why
Escaped hash patterns such as
\#*#must ignore Emacs autosave files. This finishes @wangzhengzhuo05's contribution in #1540 for #1539 and addresses the Codex P2:\#foomust match#foo, without excluding#foo.Fixes #1539. Replacement for #1540.
What Changed
Both
.bmignoreand project.gitignoreload escaped hashes while preserving significant leading whitespace. Unescaped trailing spaces are discarded; escaped spaces remain literal.Implementation Details
Preserves @wangzhengzhuo05's original commit
fbffd1a11798cc947fd47d447b4c55899980f6ec, rebased as6d47871a6a8625c53da5705e6f8a2fffe5a03a16, with its author and DCO signoff intact.git range-diffconfirms the contributor patch is unchanged. The maintainer correction is a separate signed-off commit on top of current main (ffbb6e9d66b6db73aafa370f5a5386bff3cb9186).The shared line parser removes line endings, skips comments at column zero, and decodes escaped hashes, spaces, and backslashes together before passing patterns to the existing fnmatch matcher. This preserves escape pairing and avoids stripping leading whitespace. No dependency or default ignore patterns changed.
Testing
uv run pytest tests/cli/test_ignore_utils.py -q: 39 passed, including 22 new cases across both loaders for leading whitespace,\#foo, trailing tabs, CRLF, and escaped/unescaped trailing spaces.git check-ignore --no-indexcomparison: all 22 positive/negative filename expectations agree with Git.just fast-check: passed (ruff lint, format, and fulljust typecheck). The fresh environment initially lacked optional pymilvus; installed the declaredpymilvus>=3.0.0,<4dependency and reran successfully.just doctor: passed, including file creation, indexing, search, and status in an isolated temporary project.git diff --check: passed.Risks / Follow-ups
This remains the existing fnmatch-based subset of gitignore syntax; it does not introduce full gitignore matching or negation support. CI and exact-head Codex review must complete before merge. This PR is intentionally left unmerged.