Skip to content

Fix brace expansion and whitespace in CLI pattern options #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 19, 2025

Conversation

pranshugupta01
Copy link
Contributor

@pranshugupta01 pranshugupta01 commented Apr 6, 2025

Issue
The CLI --include and --ignore options had two issues with pattern handling:

  • Brace expansion patterns like /{tests,theme}/ were incorrectly split at the comma inside braces, resulting in broken patterns ["/{tests", "theme}/"]
  • Whitespace in patterns like /tests/, /theme/ was preserved, causing unexpected behavior with leading/trailing spaces

Solution

  • Added a new splitPatterns utility function that tracks brace nesting level to preserve brace expansion patterns
  • Enhanced pattern handling to trim whitespace from each pattern
  • Added comprehensive tests for both behaviors

Before :

"**/{__tests__,theme}/**" → ["**/{__tests__", "theme}/**"] // Incorrectly split brace pattern
"**/__tests__/**, **/theme/**" → ["**/__tests__/**", " **/theme/**"] // Note the leading space

After :

"**/{__tests__,theme}/**" → ["**/{__tests__,theme}/**"] // Correctly preserves brace expansion
"**/__tests__/**, **/theme/**" → ["**/__tests__/**", "**/theme/**"] // Whitespace trimmed

Checklist

  • Run npm run test
  • Run npm run lint

Copy link

codecov bot commented Apr 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.17%. Comparing base (2572260) to head (ee4fd0f).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #469      +/-   ##
==========================================
+ Coverage   85.07%   85.17%   +0.09%     
==========================================
  Files          87       88       +1     
  Lines        4323     4350      +27     
  Branches      848      857       +9     
==========================================
+ Hits         3678     3705      +27     
  Misses        645      645              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pranshugupta01
Copy link
Contributor Author

Hey @yamadashy PR for fixing #467

@pranshugupta01
Copy link
Contributor Author

Hey @yamadashy please look into this once available

@yamadashy
Copy link
Owner

@pranshugupta01
Thank you very much for your support!

The pattern parsing functionality works excellently.
However, when testing it in practice, I found that the curly braces {} are being escaped before being passed to globby, which prevents them from working properly.
The escaping of {} was introduced in this PR:
https://github.com/yamadashy/repomix/pull/337/files#diff-ee05759c6c10ad8a41a3cbc51e775644cec0064109359136d0e80f9946de220bR68

Since curly braces {} are used for glob patterns, I've modified the code to avoid escaping them.

The code is now working as expected, so I'll go ahead and merge this PR!

Thank you so much for your contribution!

@yamadashy yamadashy mentioned this pull request Apr 19, 2025
2 tasks
@yamadashy yamadashy merged commit 19d0d5f into yamadashy:main Apr 19, 2025
52 checks passed
@pranshugupta01 pranshugupta01 deleted the enhance/brace-expansion branch April 19, 2025 07:28
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.

2 participants