Skip to content

feat(core): Improve .gitignore handling with globby v16#964

Merged
yamadashy merged 8 commits intomainfrom
feat/improve-ignore
Nov 24, 2025
Merged

feat(core): Improve .gitignore handling with globby v16#964
yamadashy merged 8 commits intomainfrom
feat/improve-ignore

Conversation

@yamadashy
Copy link
Owner

Summary

This PR updates globby from v15 to v16 and improves .gitignore handling to match Git's standard behavior.

Key Changes

  1. Update globby to v16: Upgraded from v15.0.0 to v16.0.0
  2. Improve .gitignore handling: Added gitignore: true option to respect parent directory .gitignore files, matching Git's standard behavior
  3. Refactor for maintainability: Extracted createBaseGlobbyOptions helper function to centralize common globby options across all 4 calls (searchFiles files/dirs, listDirectories, listFiles)
  4. Add comprehensive tests: Added regression tests to prove no degradation from v15 to v16 upgrade

Breaking Change Context

While globby v16 introduced a breaking change in the gitignore option behavior, this change aligns Repomix with Git's standard behavior (respecting parent directory .gitignore files). This is why we're releasing this as a MINOR version (v1.10.0) rather than PATCH.

Benefits

  • ✅ Parent directory .gitignore files are now properly respected
  • ✅ Consistent globby options across all file search operations
  • ✅ Easier to maintain and less prone to configuration drift
  • ✅ Full test coverage with 856 passing tests

Checklist

  • Run npm run test (856 tests passed)
  • Run npm run lint (all checks passed)

Copilot AI review requested due to automatic review settings November 24, 2025 07:30
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

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.

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

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Upgrades globby from v15 to v16, refactors file search operations to centralize globby options via a new createBaseGlobbyOptions() helper, replaces explicit .gitignore handling with globby's native gitignore flag, and exposes listDirectories and listFiles as public utilities with updated test coverage.

Changes

Cohort / File(s) Summary
Dependency updates
package.json
Updated globby from ^15.0.0 to ^16.0.0; @repomix/tree-sitter-wasms added and removed (no net change)
File search refactoring
src/core/file/fileSearch.ts
Introduced createBaseGlobbyOptions() helper to centralize globby configuration; refactored searchFiles(), listFiles(), and listDirectories() to reuse base options; replaced explicit ignoreFiles with globby's gitignore flag; normalized ignore patterns and added git worktree handling
Test updates and new exports
tests/core/file/fileSearch.test.ts
Exposed listDirectories() and listFiles() as public utilities; added test scenarios for v16 gitignore behavior, consistency across globby invocations, and conditional Windows-specific tests; adjusted expectations for gitignore handling

Sequence Diagram

sequenceDiagram
    participant caller as Caller
    participant search as searchFiles<br/>listFiles<br/>listDirectories
    participant helper as createBaseGlobbyOptions
    participant globby as globby
    
    caller->>search: Request with config
    search->>helper: Call to get base options
    helper->>helper: Normalize ignore patterns<br/>Handle git worktree<br/>Build options object
    helper-->>search: Return base options
    search->>globby: Call with base options +<br/>patterns
    globby-->>search: File list / Error
    search-->>caller: Return results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • createBaseGlobbyOptions() function: Review consolidation logic, ensure all option fields are correctly assembled, and verify consistent application across searchFiles(), listFiles(), and listDirectories()
  • Gitignore handling transition: Confirm that moving from explicit ignoreFiles to globby's gitignore flag preserves existing behavior and aligns with v16 expectations
  • Ignore pattern normalization: Examine the logic for normalizing patterns and handling git worktree adjustments (.git/** removal, .git addition)
  • Test coverage: Verify new test scenarios adequately cover v16-specific behavior and consistency checks across all globby invocations

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: upgrading globby to v16 and improving .gitignore handling, which aligns with the primary objectives and code changes.
Description check ✅ Passed The PR description includes a comprehensive summary, key changes, breaking change context, and benefits. However, it does not follow the provided repository template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yamadashy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances file and directory search capabilities by upgrading the globby library to its latest major version (v16) and refining how .gitignore files are processed. The core improvement ensures that Repomix now respects .gitignore rules from parent directories, mirroring Git's native behavior. This change, along with the introduction of a centralized globby options helper, makes file search operations more robust, consistent, and easier to maintain.

Highlights

  • Update globby to v16: The globby package has been upgraded from version 15 to 16, bringing the latest features and improvements to file and directory searching.
  • Improved .gitignore handling: The globby configuration now includes gitignore: true, which ensures that .gitignore files in parent directories are properly respected, aligning the behavior with Git's standard. This means files ignored by a .gitignore in an ancestor directory will now be correctly excluded from search results.
  • Refactored globby options: A new helper function, createBaseGlobbyOptions, has been extracted to centralize common globby configurations across all file search operations. This improves maintainability and consistency by ensuring all calls use the same base settings.
  • Enhanced test coverage: Comprehensive regression tests have been added to validate the globby upgrade and the new .gitignore handling. New tests also verify the consistency of globby options across different search functions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 24, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: b99d083
Status: ✅  Deploy successful!
Preview URL: https://fde9e2af.repomix.pages.dev
Branch Preview URL: https://feat-improve-ignore.repomix.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (3388b14) to head (b99d083).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #964      +/-   ##
==========================================
+ Coverage   89.68%   90.31%   +0.62%     
==========================================
  Files         111      111              
  Lines        7843     7813      -30     
  Branches     1504     1506       +2     
==========================================
+ Hits         7034     7056      +22     
+ Misses        809      757      -52     

☔ 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively upgrades globby to v16 and refactors the file searching logic to correctly handle .gitignore files, aligning with standard Git behavior. The introduction of the createBaseGlobbyOptions helper function is a good step towards improving maintainability by centralizing common options. The accompanying tests are comprehensive and cover the new functionality and refactoring well. I have one suggestion to further improve maintainability by extracting duplicated logic for preparing ignore patterns.

@claude
Copy link
Contributor

claude bot commented Nov 24, 2025

Code Review Summary

Great work on this upgrade! The implementation is solid with excellent test coverage. I've identified a few areas for consideration:

✅ Strengths

  1. Excellent refactoring: The createBaseGlobbyOptions helper function centralizes configuration and eliminates duplication across 4 call sites
  2. Comprehensive test coverage: 162 new lines of tests covering regression scenarios, consistency checks, and edge cases
  3. Clear documentation: The code comments explain the behavioral change well (parent directory .gitignore handling)
  4. Breaking change transparency: The PR description clearly explains why this is released as MINOR vs PATCH
🔍 Detailed Analysis

Code Quality

Positive:

  • Clean separation of concerns with the helper function
  • Proper TypeScript typing with Omit<GlobbyOptions, 'onlyFiles' | 'onlyDirectories'>
  • Consistent option handling across all globby calls
  • Good use of spread operator for immutability

Potential Issues:

  1. Array copying overhead: Lines 296, 298 use array spread which creates unnecessary copies since these arrays are not mutated
  2. Minor inconsistency: Package.json shows @repomix/tree-sitter-wasms was moved in the dependencies list (unrelated to this PR's scope)

Test Coverage

Excellent additions:

  • ✅ Parent directory .gitignore behavior verification (lines 343-398)
  • ✅ Consistency tests for createBaseGlobbyOptions (lines 694-788)
  • ✅ Updated expectations for gitignore option handling

Note: Tests use .runIf(!isWindows) for gitignore tests, which is appropriate given platform differences

Performance Considerations

  1. Gitignore option: The new gitignore: true option in globby v16 may have performance implications on large repos with many nested .gitignore files. Consider:

    • Monitoring performance in CI/CD on large repositories
    • Adding performance regression tests if this becomes a concern
  2. Array operations: Minor optimization opportunity by removing unnecessary array spreads in createBaseGlobbyOptions

Security Concerns

✅ No security issues identified. The upgrade:

  • Maintains proper file permission checks
  • Continues to respect ignore patterns
  • Doesn't introduce new attack vectors
🎯 Premortem Analysis: Potential Failure Scenarios

1. Performance Degradation on Large Repos

Risk: Medium
Scenario: Projects with deeply nested directory structures and many .gitignore files may see slower scan times
Mitigation:

  • Add performance benchmarks before release
  • Document the behavioral change in release notes
  • Consider adding a config option to disable deep gitignore scanning if needed

2. Behavioral Breaking Change for Users

Risk: Medium
Scenario: Users relying on v15's behavior (ignoring parent .gitignore files) will see different results
Mitigation:

  • ✅ Already addressed: Clear documentation in PR description
  • ✅ Already addressed: Releasing as MINOR version
  • Suggest: Add migration guide in release notes with before/after examples

3. Platform-Specific Issues

Risk: Low
Scenario: Windows path handling or symlink behavior differs between globby v15 and v16
Mitigation:

  • ✅ Tests include Windows-specific skips
  • Suggest: Manual testing on Windows before release

4. Integration Issues with Other Globby Options

Risk: Low
Scenario: The new gitignore: true option might conflict with ignoreFiles in edge cases
Mitigation:

  • ✅ Well tested in consistency tests
  • Code correctly separates .gitignore handling (via gitignore option) from .ignore/.repomixignore (via ignoreFiles)

5. Git Worktree Edge Cases

Risk: Low
Scenario: Complex git worktree setups might behave unexpectedly with new gitignore handling
Mitigation:

  • ✅ Existing worktree tests maintained
  • The gitignore option should respect worktree-specific ignore patterns

📝 Recommendations

  1. Minor optimization: Remove unnecessary array spreads in createBaseGlobbyOptions (lines 296, 298)
  2. Release notes: Include before/after examples of the .gitignore behavior change
  3. Consider: Add a brief performance test or benchmark for regression testing
  4. Package.json: Unrelated change to @repomix/tree-sitter-wasms ordering - consider reverting or noting in commit message

✨ Verdict

LGTM with minor suggestions. This is a well-executed upgrade with thoughtful refactoring and comprehensive testing. The behavioral change is properly documented and the code quality is high.


Reviewed following CLAUDE.md guidelines

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/core/file/fileSearch.ts (1)

148-176: Consider extracting shared ignore‑context preparation to reduce duplication

searchFiles, listDirectories, and listFiles all duplicate the same sequence: getIgnorePatterns/getIgnoreFilePatterns, normalizeGlobPattern, and git worktree adjustment logic. Pulling this into a small helper (e.g., prepareIgnoreContext(rootDir, config)) would keep future changes to ignore behavior in one place and make the globby call sites even thinner.

Also applies to: 383-405, 423-445

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a63546b and a1d92ab.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/core/file/fileSearch.ts (7 hunks)
  • tests/core/file/fileSearch.test.ts (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/core/file/fileSearch.ts (1)
src/config/configSchema.ts (1)
  • RepomixConfigMerged (157-157)
🪛 GitHub Actions: CI
tests/core/file/fileSearch.test.ts

[error] 730-730: TS18048: 'options' is possibly 'undefined'.

🪛 GitHub Check: Lint TypeScript
tests/core/file/fileSearch.test.ts

[failure] 731-731:
'options' is possibly 'undefined'.


[failure] 730-730:
'options' is possibly 'undefined'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
package.json (1)

83-91: globby v16 dependency bump looks consistent with the implementation

The upgrade to "globby": "^16.0.0" matches the new typed GlobbyOptions usage and gitignore-related behavior in fileSearch.ts; nothing blocking here from a manifest perspective.

tests/core/file/fileSearch.test.ts (2)

12-14: Tests correctly reflect new gitignore vs ignoreFiles split

The updated getIgnoreFilePatterns tests and comments align with the implementation: .gitignore is no longer part of ignoreFiles and is governed purely by the gitignore option, while .ignore and .repomixignore are controlled by config flags. This gives good coverage of the new ignore‑file behavior.

If you’d like, you can also add a small assertion in one test that gitignore toggling actually flips the gitignore flag in the globby options (similar to later tests), to more tightly couple these tests to the runtime behavior.

Also applies to: 58-71, 73-85, 87-100


287-289: Parent .gitignore behavior and gitignore flag coverage look solid

The new tests that (1) assert gitignore: true is present in the globby options and (2) simulate a parent .gitignore file filtering nested files give good regression protection for the globby v16 change around gitignore handling. The runIf(!isWindows) guard is also appropriate given path‑separator differences.

It’s worth re‑running these tests against an actual repo with nested .gitignore files to confirm that the mocked behavior matches globby v16’s real behavior on your target platforms.

Also applies to: 343-398

src/core/file/fileSearch.ts (1)

4-5: Verify performance implications of gitignore: true conditional usage

Verification against globby v16 docs shows that the recommended approach for combining .gitignore with custom ignore files is to use ignoreFiles with .gitignore explicitly listed (e.g., ignoreFiles: ['.gitignore', '.ignore', ...]) rather than gitignore: true, which can incur scanning overhead.

Your implementation uses gitignore: config.ignore.useGitignore conditionally alongside ignoreFiles: [...ignoreFilePatterns]. The code comment explains this is intentional—to properly respect parent directory .gitignore files the way Git does. This is a legitimate design choice but comes with a performance tradeoff when the gitignore option is enabled.

If performance is a concern and Git behavior compatibility is not a hard requirement, consider whether switching to explicit ignoreFiles: ['.gitignore', '**/.ignore', '**/.repomixignore'] (if globby supports it) would be acceptable. Otherwise, document this tradeoff clearly so future maintainers understand the choice.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

yamadashy added a commit that referenced this pull request Nov 24, 2025
This commit addresses three suggestions from AI code review bots on PR #964:

1. Remove unnecessary array spreads in createBaseGlobbyOptions
   - Removed defensive copying of ignorePatterns and ignoreFilePatterns
   - Arrays are already created fresh in calling functions, making spreads redundant
   - Minor performance optimization by avoiding unnecessary array allocations

2. Extract prepareIgnoreContext helper function
   - Centralized duplicate ignore pattern preparation logic
   - Eliminated code duplication across searchFiles, listDirectories, and listFiles
   - The new helper handles:
     * Getting ignore patterns and ignore file patterns
     * Normalizing patterns for consistent trailing slash handling
     * Git worktree special case handling
   - Improves maintainability and ensures consistency across all globby calls

3. Add explanatory comment to v16 behavior test
   - Documented why v16's behavior is superior (matches Git's standard behavior)
   - Clarifies that v16 respects parent directory .gitignore files
   - Helps future maintainers understand the intentional breaking change

All 856 tests pass with no regressions.
@claude
Copy link
Contributor

claude bot commented Nov 24, 2025

Code Review - Incremental Feedback

This review focuses on new issues not previously covered by other reviewers.

Critical Issue: TypeScript Lint Error

Must fix before merge: The CI is failing due to a TypeScript error in tests/core/file/fileSearch.test.ts:730-731. See my inline comment for the fix - options needs a type guard since call[1] might be undefined.

Premortem Analysis: Additional Failure Scenarios

Building on previous reviews, here are NEW risks not yet discussed:

1. Globby v16 ignoreFiles Behavior Change (Risk: High)

In v15, all ignore files went through ignoreFiles. In v16, you split them - .gitignore via gitignore:true, others via ignoreFiles. This could cause edge cases where parent directory .ignore files might not be respected the same way as parent .gitignore files.

Mitigation: Add integration tests with nested .ignore and .repomixignore files to verify they work like .gitignore.

2. Node.js Version Compatibility (Risk: Medium)

Globby v16 requires Node.js >=20 per package-lock.json. If Repomix doesn't already require Node 20+, this needs to be a MAJOR version bump (v2.0.0), not minor.

Action: Verify package.json engines field and update release notes accordingly.

3. is-path-inside vs path-type Dependency Swap (Risk: Low)

Globby v16 replaced path-type with is-path-inside. Could affect symlink handling and Windows junction points.

Mitigation: Manual testing with symlinks recommended.

4. Git Worktree + Parent .gitignore Interaction (Risk: Low-Medium)

The worktree handling code modifies patterns when .git is a worktree reference. With v16's parent .gitignore support, interactions need validation.

Mitigation: Add test case for worktrees with parent directory .gitignore.

Test Coverage Gaps

Missing tests for:

  • Interaction between gitignore:true and ignoreFiles in same directory
  • Parent directory .ignore file handling
  • Performance regression for large repos (optional)

Positive Changes

  1. Excellent refactoring eliminates ~80 lines of duplication
  2. Smart use of Omit for type safety
  3. Clear documentation of .gitignore vs ignoreFiles separation

Action Items Before Merge

  1. Fix TypeScript lint error (critical - blocking)
  2. Verify Node.js version requirement
  3. Consider adding parent .ignore test

Overall: Strong implementation with one blocking lint error. The refactoring significantly improves maintainability.

@claude
Copy link
Contributor

claude bot commented Nov 24, 2025

Node.js Version Check: Confirmed that package.json already requires Node >=20.0.0, so the globby v16 upgrade is compatible. No action needed on this front.

yamadashy and others added 7 commits November 24, 2025 17:44
- Upgrade globby from v15 to v16
- Use gitignore option to respect parent directory .gitignore files
- This matches Git's standard behavior where parent .gitignore patterns apply to subdirectories
- Move .gitignore handling from ignoreFiles to gitignore option
- Update tests to reflect the new behavior

This change improves compatibility with Git and provides more accurate file filtering when running Repomix in subdirectories.
- Add createBaseGlobbyOptions function to centralize common globby options
- Use Omit<GlobbyOptions, 'onlyFiles' | 'onlyDirectories'> for type safety
- Update all 4 globby calls to use the shared helper
- This prevents configuration drift and makes future updates easier

No behavior changes - all tests pass.
- Add test for parent directory .gitignore pattern handling (v16 behavior)
- Add tests for createBaseGlobbyOptions consistency across all functions
- Verify gitignore option is passed correctly to all globby calls
- Ensure no regression from v15 to v16 upgrade

These tests prove that:
1. Parent .gitignore files are respected with globby v16
2. All 4 globby calls (searchFiles files/dirs, listDirectories, listFiles)
   use consistent base options
3. gitignore configuration is applied uniformly across all functions

All 856 tests pass, confirming no regression from the changes.
- Add website/server/dist/ to .gitignore for secretlint
- Fix TypeScript type errors in fileSearch.test.ts
- Format imports in fileSearch.ts (biome)
This commit addresses three suggestions from AI code review bots on PR #964:

1. Remove unnecessary array spreads in createBaseGlobbyOptions
   - Removed defensive copying of ignorePatterns and ignoreFilePatterns
   - Arrays are already created fresh in calling functions, making spreads redundant
   - Minor performance optimization by avoiding unnecessary array allocations

2. Extract prepareIgnoreContext helper function
   - Centralized duplicate ignore pattern preparation logic
   - Eliminated code duplication across searchFiles, listDirectories, and listFiles
   - The new helper handles:
     * Getting ignore patterns and ignore file patterns
     * Normalizing patterns for consistent trailing slash handling
     * Git worktree special case handling
   - Improves maintainability and ensures consistency across all globby calls

3. Add explanatory comment to v16 behavior test
   - Documented why v16's behavior is superior (matches Git's standard behavior)
   - Clarifies that v16 respects parent directory .gitignore files
   - Helps future maintainers understand the intentional breaking change

All 856 tests pass with no regressions.
Fix TS18048 errors in createBaseGlobbyOptions consistency tests by adding
expect(options).toBeDefined() and if (!options) continue guards. This ensures
type safety and prevents undefined access to globby call options.

All three tests now properly guard against potentially undefined options:
- should use consistent base options across all globby calls
- should respect gitignore config consistently across all functions
- should apply custom ignore patterns consistently across all functions

This addresses the coderabbitai feedback on PR #964.
@claude
Copy link
Contributor

claude bot commented Nov 24, 2025

Code Review - PR #964

I've reviewed this PR and identified some new issues not mentioned in previous reviews:

🐛 Issues Found

  1. TypeScript Linting Error (tests/core/file/fileSearch.test.ts:740)

    • Redundant if (options) check after if (!options) continue guard
    • This is causing the CI TypeScript lint failure
    • See inline comment for suggested fix
  2. Unrelated Dependency Reordering (package.json:82)

    • @repomix/tree-sitter-wasms moved from line 103 to line 82
    • Appears unrelated to the globby upgrade
    • Should either be reverted or explained in commit message

✅ Positive Observations

Click to expand

Code Quality:

  • Excellent refactoring with createBaseGlobbyOptions helper - eliminates duplication across 4 call sites
  • prepareIgnoreContext helper further reduces duplication (as noted by CodeRabbit)
  • Clear separation of concerns between .gitignore handling (via gitignore option) and other ignore files

Test Coverage:

  • Comprehensive test additions (162 new lines)
  • Good coverage of parent directory .gitignore behavior (v16 feature)
  • Consistency tests across all globby invocations
  • Appropriate platform-specific test guards for Windows

Documentation:

  • Clear inline comments explaining the behavioral change
  • PR description thoroughly explains the breaking change rationale

🎯 Premortem Analysis

Potential failure scenarios not covered by previous reviews

1. Monorepo Performance Impact

  • Risk: Medium
  • Scenario: In monorepos with many nested .gitignore files (e.g., Nx/Turborepo workspaces), the new parent directory .gitignore scanning could impact performance
  • Mitigation: Consider adding a performance benchmark test for repos with 10+ nested .gitignore files

2. Symbolic Link Edge Cases

  • Risk: Low
  • Scenario: The interaction between followSymbolicLinks: false and the new gitignore: true behavior is untested. If a symlink points to a directory with its own .gitignore, behavior might differ from v15
  • Mitigation: Add a test case with symbolic links and .gitignore files

3. Case-Sensitive Filesystem Differences

  • Risk: Low
  • Scenario: The .gitignore behavior change might have different implications on case-sensitive (Linux) vs case-insensitive (macOS/Windows) filesystems
  • Mitigation: The existing Windows test guards are good, but consider explicit testing on macOS CI if available

4. Git Submodule Interactions

  • Risk: Low
  • Scenario: Repositories with git submodules might have unexpected .gitignore interactions with the new v16 parent directory scanning
  • Mitigation: Add test coverage for repositories with submodules

📋 Action Items

Must Fix:

  • Fix TypeScript linting error at line 740 in tests/core/file/fileSearch.test.ts
  • Address or explain the @repomix/tree-sitter-wasms reordering in package.json

Nice to Have:

  • Consider CodeRabbit's suggestion to extract prepareIgnoreContext pattern logic into a reusable helper
  • Add performance benchmark test for nested .gitignore scenarios
  • Add test case for symbolic links with .gitignore files

📊 Overall Assessment

Verdict: Approve with required fixes ✅

The core implementation is solid and well-tested. The globby v16 upgrade is properly handled with good backward compatibility considerations. Once the TypeScript linting error is fixed and the package.json change is addressed, this PR will be ready to merge.

The behavioral change (respecting parent .gitignore files) is well-documented and appropriate for a minor version bump.


Review conducted following CLAUDE.md guidelines

Add comprehensive tests for parent directory ignore file handling to address
PR #964 review feedback (Risk: High concern from claude[bot]).

Added three new test cases:

1. Parent directory .ignore file handling
   - Verifies .ignore files in parent directories are respected
   - Tests with useDotIgnore: true configuration
   - Ensures patterns apply to nested subdirectories

2. Parent directory .repomixignore file handling
   - Verifies .repomixignore files in parent directories are respected
   - Tests default configuration (.repomixignore always enabled)
   - Ensures patterns apply to nested subdirectories

3. Git worktree + parent .gitignore interaction
   - Verifies worktree environments handle parent .gitignore correctly
   - Combines worktree detection with parent .gitignore pattern application
   - Tests that .git file (not directory) is properly handled in worktree
   - Ensures gitignore: true option enables parent .gitignore handling

All tests follow the same pattern as existing "should respect parent directory
.gitignore patterns (v16 behavior)" test, providing consistent coverage for
.gitignore, .ignore, and .repomixignore files.

These tests ensure that globby v16's parent directory ignore file handling
works correctly for all supported ignore file types, not just .gitignore.
@claude
Copy link
Contributor

claude bot commented Nov 24, 2025

Code Review - Additional Analysis

Excellent work on the globby v16 upgrade! The refactoring is well-executed with comprehensive test coverage. Since other reviewers have covered many aspects, I'll focus on new observations:

✅ Strengths (Beyond What's Already Mentioned)
  1. Excellent type safety: The use of Omit<GlobbyOptions, 'onlyFiles' | 'onlyDirectories'> is a clever way to ensure type-safe option sharing while preventing conflicting options at compile time (fileSearch.ts:311).

  2. Thorough edge case coverage: The worktree + parent .gitignore interaction test (lines 595-633 in test file) demonstrates excellent attention to complex edge cases that combine multiple features.

  3. Performance-conscious: The use of Promise.all() in prepareIgnoreContext (line 276) ensures parallel execution of I/O operations, maintaining good performance.

  4. Clear separation of concerns: The prepareIgnoreContext helper (lines 264-300) successfully eliminates ~75 lines of duplication across 3 functions - excellent DRY principle application.

🔍 New Observations & Suggestions

1. Documentation Enhancement Opportunity

Location: src/core/file/fileSearch.ts:331-332

The comment explaining why .gitignore is handled differently is excellent, but consider adding a brief note about when this behavior changed (globby v16) to help future maintainers understand the evolution:

// .gitignore files are handled by globby's gitignore option (not ignoreFiles)
// to properly respect parent directory .gitignore files, matching Git's behavior.
// This changed in globby v16 - previously .gitignore was treated like other ignore files.

2. Potential Test Reliability Issue

Location: Test file lines 343-402, 404-462, 464-522

Risk Level: Low

The parent directory ignore file tests use mocked globby that simulates filtering behavior. However, these tests don't verify that the actual globby v16 library performs this filtering - they only verify that the correct options are passed.

Suggestion: Consider adding at least one integration test (perhaps in a separate suite) that uses the real globby library with actual temporary files and .gitignore to verify end-to-end behavior. This would catch any misunderstandings about how globby v16's gitignore option actually works.

3. Minor Code Clarity Enhancement

Location: src/core/file/fileSearch.ts:289-296

The worktree handling logic uses array mutation (splice + push). While correct, consider a more functional approach for clarity:

const adjustedIgnorePatterns = isWorktree
  ? normalizedIgnorePatterns.map(p => p === '.git/**' ? '.git' : p)
  : [...normalizedIgnorePatterns];

This is purely stylistic - the current implementation is fine.

4. Coverage Gap: Multiple .gitignore Files

Location: Test suite

Risk Level: Medium

The tests verify parent .gitignore behavior, but don't test scenarios where multiple .gitignore files exist at different levels (e.g., root/.gitignore and root/subdir/.gitignore with potentially conflicting patterns). Git has specific precedence rules for this - closer .gitignore files take precedence.

Recommendation: Add a test case verifying that when a parent .gitignore ignores *.log but a subdirectory .gitignore has !important.log, the negation pattern is respected. This would ensure globby v16's behavior matches Git's precedence rules.

5. Breaking Change Communication

Location: PR Description

The PR description is excellent, but when this is released, ensure the release notes include:

  • Migration guide: Specific examples showing before/after behavior for users who might be affected
  • Rollback instructions: How to temporarily revert to v15 behavior if needed (though there's no config option for this, which might be intentional)
  • Performance notes: Any observed performance differences on large repos with many nested .gitignore files
🎯 Premortem: Additional Failure Scenarios

6. Symbolic Link + .gitignore Interaction

Risk: Low-Medium
Scenario: A symbolic link points to a directory with its own .gitignore. Globby v16 might handle parent .gitignore differently for symlinked directories.

Mitigation:

  • The code already has followSymbolicLinks: false which reduces this risk
  • Consider documenting this behavior if users request symlink support

7. .git/info/exclude Compatibility

Risk: Low
Scenario: The code reads .git/info/exclude patterns and adds them to the ignore array (line 372-387), but globby's gitignore option might also read this file, potentially causing duplicate processing.

Investigation needed: Verify whether globby v16's gitignore option already processes .git/info/exclude. If so, the current code might be redundant (though harmless).

File: src/core/file/fileSearch.ts:372-387

8. Case-Sensitive Filesystem Edge Cases

Risk: Low
Scenario: On case-insensitive filesystems (macOS, Windows), a .gitignore pattern like Test/ might behave differently than expected if the actual directory is named test/.

Note: This is a globby/Git behavior, not specific to this PR, but worth documenting if users report issues.

📊 Code Quality Metrics
  • Lines of code removed: -30 net change with improved functionality ✅
  • Code duplication eliminated: ~75 lines (3x ~25 line blocks) ✅
  • Test coverage delta: +395 lines of tests for -30 lines of production code (13:1 ratio) ✅
  • Cyclomatic complexity: Reduced through helper function extraction ✅
  • Type safety: Enhanced with proper TypeScript generics ✅

🎬 Final Verdict

LGTM - This is a high-quality PR with excellent refactoring and test coverage. The suggestions above are minor enhancements and edge cases to consider, not blockers. The code is ready to merge.

The most important follow-ups are:

  1. Consider one real integration test with actual globby (not mocked)
  2. Add a test for multiple .gitignore files at different levels
  3. Verify .git/info/exclude handling isn't duplicated by globby

Estimated risk of production issues: Very Low (< 5%)


Review completed following CLAUDE.md guidelines. Previous feedback from CodeRabbit and Gemini bots was considered to avoid duplication.

@yamadashy yamadashy merged commit 80c35d4 into main Nov 24, 2025
55 checks passed
@yamadashy yamadashy deleted the feat/improve-ignore branch November 24, 2025 10:43
hztBUAA added a commit to hztBUAA/repomix that referenced this pull request Feb 20, 2026
…yamadashy#959)

Add comprehensive test coverage to verify that .ignore files work correctly
when customPatterns is defined in the configuration. The issue reported that
.ignore files were ignored when customPatterns was set, but investigation
shows this was resolved by the globby v16 upgrade in PR yamadashy#964.

Changes:
- Add config merge tests verifying useDotIgnore is preserved when
  customPatterns is defined (tests/config/configLoad.test.ts)
- Add integration tests using real file system to verify .ignore,
  .repomixignore, and customPatterns are all merged correctly
  (tests/core/file/fileSearch.ignore.integration.test.ts)
- Add clarifying comment in getIgnoreFilePatterns documenting that
  ignore file patterns are applied independently of customPatterns
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