Skip to content

fix: respect .ignore file when customPatterns is defined#1165

Open
hztBUAA wants to merge 1 commit intoyamadashy:mainfrom
hztBUAA:fix/ignore-file-with-custom-patterns
Open

fix: respect .ignore file when customPatterns is defined#1165
hztBUAA wants to merge 1 commit intoyamadashy:mainfrom
hztBUAA:fix/ignore-file-with-custom-patterns

Conversation

@hztBUAA
Copy link
Copy Markdown

@hztBUAA hztBUAA commented Feb 20, 2026

Summary

Closes #959

The reported issue was that .ignore files were being ignored when customPatterns was defined in the configuration. Investigation shows that this was resolved by the globby v16 upgrade in PR #964, which improved .gitignore handling and moved it to globby's native gitignore option.

This PR adds regression test coverage to ensure the fix stays in place:

  • Config merge tests (tests/config/configLoad.test.ts): Verify that useDotIgnore defaults to true and is preserved when only customPatterns is defined in the file or CLI config
  • Integration tests (tests/core/file/fileSearch.ignore.integration.test.ts): Use real file system operations to verify that .ignore, .repomixignore, and customPatterns are all properly merged and applied together
  • Code documentation (src/core/file/fileSearch.ts): Add clarifying comment in getIgnoreFilePatterns documenting that ignore file patterns are applied independently of customPatterns

Test scenarios covered

  1. .ignore respected when customPatterns is defined via config file merge
  2. .ignore respected when customPatterns is empty
  3. .ignore NOT applied when useDotIgnore is explicitly false
  4. All three ignore sources (.ignore, .repomixignore, customPatterns) merged together
  5. Subdirectory .ignore files work alongside customPatterns
  6. Config merge preserves boolean ignore flags when only customPatterns is provided

Checklist

  • Run npm run test
  • Run npm run lint

Open with Devin

…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
@hztBUAA hztBUAA requested a review from yamadashy as a code owner February 20, 2026 05:48
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hztBUAA, 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 addresses an issue where .ignore files were not respected when customPatterns was configured. While the underlying fix was already implemented through a globby library upgrade, this PR ensures the robustness of this behavior by introducing extensive regression tests and clarifying relevant code documentation. The new tests validate correct merging of various ignore sources and proper application of .ignore files in different scenarios.

Highlights

  • Regression Test Coverage: Added comprehensive regression tests for .ignore file behavior, specifically when customPatterns is defined, covering config merge and real file system integration scenarios.
  • Documentation Update: Updated fileSearch.ts with a clarifying comment explaining that ignore file patterns are always applied, independent of customPatterns.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/core/file/fileSearch.ts
    • Added a comment clarifying that ignore file patterns are always applied, regardless of customPatterns.
  • tests/config/configLoad.test.ts
    • Added tests to verify useDotIgnore defaults and preservation during config merges when customPatterns is present.
    • Included a test to ensure explicit useDotIgnore: false is respected.
  • tests/core/file/fileSearch.ignore.integration.test.ts
    • Added a new integration test file to validate .ignore file behavior with customPatterns using real file system operations.
    • Included tests for scenarios like .ignore with empty customPatterns, disabling .ignore, merging all ignore sources, and subdirectory .ignore files.
Activity
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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

This PR addresses issue #959 by adding documentation and regression tests for the ignore file pattern merging behavior when customPatterns is defined. It includes a clarifying comment in the core search logic and comprehensive test coverage for configuration merging and integration scenarios.

Changes

Cohort / File(s) Summary
Core Documentation
src/core/file/fileSearch.ts
Added clarifying comment explaining that ignore file patterns are always applied and merged by globby at the search level, independent of customPatterns.
Configuration Tests
tests/config/configLoad.test.ts
Added regression tests validating mergeConfigs behavior when customPatterns is defined in file or CLI config, ensuring default ignore flags remain true and patterns are correctly merged.
Integration Tests
tests/core/file/fileSearch.ignore.integration.test.ts
Added comprehensive integration test suite validating .ignore behavior with customPatterns across multiple scenarios: merging with .ignore/.repomixignore, respecting useDotIgnore flag, and subdirectory .ignore handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • yamadashy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: ensuring .ignore files are respected when customPatterns is defined.
Description check ✅ Passed The description is well-structured with clear sections explaining the fix, test coverage, and scenarios. All required checklist items are marked as completed.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #959 by adding regression tests and documentation to ensure .ignore, .repomixignore, and customPatterns are properly merged and applied together.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing and testing the .ignore file behavior with customPatterns. No unrelated or out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
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

The pull request provides excellent regression test coverage for the issue where .ignore files were being ignored when customPatterns was defined. It includes both configuration merging unit tests and comprehensive integration tests using real file system operations. The added documentation in fileSearch.ts clarifies the expected behavior. The changes are well-structured and follow the project's existing patterns. No issues of medium or higher severity were identified.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
tests/core/file/fileSearch.ignore.integration.test.ts (1)

39-46: Consider using createMockConfig consistently instead of manual spread override.

Test 1 uses mergeConfigs then manually overrides the result with spread syntax (Line 44), which bypasses the Zod schema validation that mergeConfigs applies. The other tests use createMockConfig directly. Using createMockConfig here too would be more consistent and avoid the unvalidated override.

That said, the intent to show the mergeConfigs path for the exact #959 reproduction scenario is understood.

♻️ Proposed refactor using createMockConfig
-    // Simulate: config file has { ignore: { customPatterns: ["bin/"] } }
-    const fileConfig: RepomixConfigFile = {
-      ignore: { customPatterns: ['bin/'] },
-    };
-    const config = mergeConfigs(tempDir, fileConfig, {});
-    const testConfig = { ...config, ignore: { ...config.ignore, useGitignore: false, useDefaultPatterns: false } };
+    // Simulate: config file has { ignore: { customPatterns: ["bin/"] } }
+    const testConfig = createMockConfig({
+      cwd: tempDir,
+      ignore: {
+        useGitignore: false,
+        useDotIgnore: true,
+        useDefaultPatterns: false,
+        customPatterns: ['bin/'],
+      },
+    });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/core/file/fileSearch.ignore.integration.test.ts` around lines 39 - 46,
Replace the manual spread override of the merged config with a call to
createMockConfig to ensure Zod validation is applied: instead of calling
mergeConfigs(tempDir, fileConfig) then constructing testConfig via { ...config,
ignore: { ... } }, call createMockConfig(tempDir, fileConfig, { ignore: {
useGitignore: false, useDefaultPatterns: false } }) (or equivalent
createMockConfig overload) and pass that result to searchFiles; update
references to fileConfig, mergeConfigs, testConfig, and searchFiles accordingly
so the test uses the validated mock config consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/core/file/fileSearch.ignore.integration.test.ts`:
- Around line 39-46: Replace the manual spread override of the merged config
with a call to createMockConfig to ensure Zod validation is applied: instead of
calling mergeConfigs(tempDir, fileConfig) then constructing testConfig via {
...config, ignore: { ... } }, call createMockConfig(tempDir, fileConfig, {
ignore: { useGitignore: false, useDefaultPatterns: false } }) (or equivalent
createMockConfig overload) and pass that result to searchFiles; update
references to fileConfig, mergeConfigs, testConfig, and searchFiles accordingly
so the test uses the validated mock config consistently.

@hztBUAA
Copy link
Copy Markdown
Author

hztBUAA commented Feb 25, 2026

Thanks for the review and feedback. I am following up on this PR now and will either push the requested changes or reply point-by-point shortly.

@hztBUAA
Copy link
Copy Markdown
Author

hztBUAA commented Feb 25, 2026

Quick follow-up: I am reviewing the feedback and will update this PR shortly.

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: .ignore file is ignored when customPatterns is defined in config

1 participant