Skip to content

fix(file): Stop appending /** to ignore rules that end in a wildcard - #1877

Open
sxh313 wants to merge 2 commits into
yamadashy:mainfrom
sxh313:fix/ignore-glob-trailing-wildcard
Open

sxh313 wants to merge 2 commits into
yamadashy:mainfrom
sxh313:fix/ignore-glob-trailing-wildcard

Conversation

@sxh313

@sxh313 sxh313 commented Sep 21, 2026

Copy link
Copy Markdown

Fixes #1876

Five built-in default ignore rules end in a bare wildcard (**/npm-debug.log*, **/yarn-debug.log*, **/yarn-error.log*, **/repomix-output.*, **/repopack-output.*) and none of them ignores anything today, because normalizeGlobPattern appends /** to every **/-prefixed pattern that has no inner /**. **/npm-debug.log* becomes **/npm-debug.log*/**, which in fast-glob matches only paths below a match — so the file the rule names can never be matched by it.

Visible effect on a pristine build of 9f01703a, packing a fixture that contains the files those rules name:

$ node bin/repomix.cjs . -o /tmp/out.xml && grep -o 'path="[^"]*"' /tmp/out.xml
path="docs/repomix-output.xml"     # **/repomix-output.*  → packed
path="src/a.ts"
path=".gitignore"
path="npm-debug.log.1"             # **/npm-debug.log*    → packed
path="probe-xyz.old1"
path="README.md"
path="repomix-output.1.xml"        # **/repomix-output.*  → packed
path="repomix-output.xml"          # **/repomix-output.*  → packed
path="yarn-error.log.old"          # **/yarn-error.log*   → packed

The repomix-output pair is the one that bites hardest: a repository with a committed previous pack anywhere in it embeds that pack into the new one, which is what those two lines exist to prevent.

It is not limited to the default list — any user pattern in that shape is inert, while the two neighbouring shapes work:

pattern passed to -i file packed?
**/probe-xyz* yes (inert)
probe-xyz* no
**/probe-xyz.old1 no

The change

The rewrite is scoped to directories by its own JSDoc ("Makes **/folder, **/folder/, and **/folder/**/* behave identically") and by the comment above it, but the guard only tests the prefix. This adds the missing shape test, so it fires only for rules that currently match nothing:

- if (pattern.startsWith('**/') && !pattern.includes('/**')) {
+ if (pattern.startsWith('**/') && !pattern.includes('/**') && !pattern.endsWith('*')) {

Verified against globby's own matcher rather than inferred: of the 86 default patterns 32 take this branch, and exactly the 5 above lose every match under it — **/node_modules/**-style directory rules and **/folder-style rules are untouched, which is why the failure is easy to miss.

After the change the same fixture packs src/a.ts, .gitignore, probe-xyz.old1, README.md only, and -i '**/probe-xyz*' now excludes the probe file. The new test pins the three built-in shapes; the existing **/bin / **/nested/folder / **/folder/** cases still assert the directory rewrite unchanged.

Deliberately out of scope: --split-output writes out.1.xml… beside out.xml, and getIgnorePatterns only adds the base output path, so a second split run re-packs the first run's parts. Different rule, different line — worth its own issue.

Checklist

  • Run npm run test
  • Run npm run lint

`normalizeGlobPattern` rewrites every `**/`-prefixed pattern without an inner
`/**`, which turns `**/npm-debug.log*` into `**/npm-debug.log*/**` — a rule that
only matches paths below a match, so the files it names are never ignored. Five
built-in default ignores are inert this way, including `**/repomix-output.*`, so
a committed previous pack gets embedded in the next one.

The rewrite is documented and commented as the directory case (`**/folder`), so
skip it when the last segment already ends with a wildcard. That only affects
rules that currently match nothing.
@sxh313
sxh313 requested a review from yamadashy as a code owner September 21, 2026 01:09
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: yamadashy/repomix/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 5473835a-b766-4a0b-9b90-b94a17b0fb56

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: yamadashy/repomix/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 0061a42c-95f6-4e46-8011-f791c1760355

📥 Commits

Reviewing files that changed from the base of the PR and between 9f01703 and 5b1f108.

📒 Files selected for processing (2)
  • src/core/file/fileSearch.ts
  • tests/core/file/fileSearch.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

normalizeGlobPattern no longer appends /** to leading **/ patterns that end with a wildcard. Tests verify this behavior for npm, Yarn, and Repomix output patterns.

Changes

Ignore Pattern Fix

Layer / File(s) Summary
Normalize wildcard patterns and validate behavior
src/core/file/fileSearch.ts, tests/core/file/fileSearch.test.ts
The normalizer preserves leading wildcard file patterns. Tests cover **/npm-debug.log*, **/yarn-error.log*, and **/repomix-output.*.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: preventing /** from being appended to wildcard-ending ignore rules.
Description check ✅ Passed The description provides a detailed summary of the bug, implementation, scope, test coverage, and completed test and lint checklist items.
Linked Issues check ✅ Passed The change in src/core/file/fileSearch.ts prevents normalizeGlobPattern from appending /** when a leading **/ pattern ends with *. This preserves the five affected built-in patterns in `src/…
Out of Scope Changes check ✅ Passed The diff changes only glob normalization and its unit tests. These changes directly address issue #1876. No split-output re-packing code or unrelated behavior is changed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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] Built-in ignore rules ending in a wildcard (**/npm-debug.log*, **/repomix-output.*) match nothing

1 participant