Skip to content

fix(ignore): use case-sensitive matching to prevent BUILD file exclusion on macOS#1166

Open
lucamorettibuilds wants to merge 3 commits intoyamadashy:mainfrom
lucamorettibuilds:fix/case-sensitive-ignore-matching
Open

fix(ignore): use case-sensitive matching to prevent BUILD file exclusion on macOS#1166
lucamorettibuilds wants to merge 3 commits intoyamadashy:mainfrom
lucamorettibuilds:fix/case-sensitive-ignore-matching

Conversation

@lucamorettibuilds
Copy link

@lucamorettibuilds lucamorettibuilds commented Feb 20, 2026

Summary

On case-insensitive file systems (macOS HFS+/APFS), the default ignore pattern build/** incorrectly matches Pants build tool's BUILD files. This one-line fix ensures ignore patterns match with exact case.

Problem

  • Default ignore has build/** (defaultIgnore.ts:111)
  • macOS HFS+/APFS is case-insensitive by default
  • BUILD files (used by Pants) get matched by build/**
  • Users can't simply add !BUILD to include patterns

Fix

Sets caseSensitiveMatch: true in createBaseGlobbyOptions(). This is a globby/fast-glob option that forces case-sensitive pattern matching regardless of the OS filesystem. build/** will only match lowercase build/ directories — not BUILD source files.

This is the simplest and most correct approach from the potential solutions listed in #980 (option 1). It also matches the behavior users expect from their .gitignore and .repomixignore patterns.

Changes

  • src/core/file/fileSearch.ts: Add caseSensitiveMatch: true to createBaseGlobbyOptions()
  • tests/core/file/fileSearch.test.ts: Update globby options assertions

Fixes #980


Open with Devin

…ion on macOS

On case-insensitive file systems (macOS HFS+/APFS), the default ignore
pattern `build/**` incorrectly matches Pants build tool's `BUILD` files.

Setting `caseSensitiveMatch: true` in globby options ensures ignore
patterns match with exact case, so `build/**` only matches lowercase
`build/` directories — not `BUILD` source files.

Fixes yamadashy#980
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lucamorettibuilds, 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 a critical issue on case-insensitive file systems, particularly macOS, where the default build/** ignore pattern inadvertently excluded important BUILD files used by the Pants build tool. By enforcing case-sensitive matching for ignore patterns, the change ensures that only directories named build (lowercase) are ignored, preventing unintended file exclusions and aligning ignore behavior with user expectations from .gitignore and .repomixignore.

Highlights

  • Case-sensitive ignore patterns: Enabled caseSensitiveMatch: true in globby options to prevent BUILD files from being incorrectly ignored on case-insensitive file systems like macOS, resolving an issue where build/** patterns would match BUILD files.
  • Test updates: Updated existing tests to assert the new caseSensitiveMatch: true option is correctly applied to globby options.

🧠 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 caseSensitiveMatch: true to createBaseGlobbyOptions().
  • tests/core/file/fileSearch.test.ts
    • Updated globby option assertions to include caseSensitiveMatch: true in createBaseGlobbyOptions().
    • Updated globby option assertions to include caseSensitiveMatch: true in createBaseGlobbyOptions() within a different test block.
Activity
  • The pull request was opened by lucamorettibuilds.
  • No human review comments or additional activity have been recorded yet.
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
Contributor

coderabbitai bot commented Feb 20, 2026

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.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A single configuration option (caseSensitiveMatch: true) is added to globby's base options to enforce case-sensitive file matching, with corresponding test assertions updated to verify this behavior.

Changes

Cohort / File(s) Summary
Case-Sensitive File Matching Configuration
src/core/file/fileSearch.ts
Added caseSensitiveMatch: true to base globby options to enforce case-sensitive file matching on all file systems.
Test Expectations
tests/core/file/fileSearch.test.ts
Updated test assertions to verify that globby is invoked with caseSensitiveMatch: true in the options.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • yamadashy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: setting case-sensitive matching for ignore patterns to prevent BUILD file exclusion on macOS.
Description check ✅ Passed The PR description comprehensively covers the problem, the fix, and the changes made, addressing all key aspects. While the optional checklist items are not marked as completed, the required sections are thorough.
Linked Issues check ✅ Passed The PR implements the primary solution (option 1) from issue #980: adding caseSensitiveMatch: true to createBaseGlobbyOptions() to ensure Pants BUILD files are not ignored on macOS.
Out of Scope Changes check ✅ Passed All changes are directly related to the fix: adding caseSensitiveMatch option to the base globby configuration and updating corresponding test assertions.
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 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
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 2 additional findings.

Open in Devin Review

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

The changes successfully address the issue where BUILD files were incorrectly ignored on case-insensitive filesystems (like macOS) due to the default build/** ignore pattern. By setting caseSensitiveMatch: true in the globby options, the tool now ensures that ignore patterns are matched with exact case. This also resolves an existing inconsistency where globby followed OS case-sensitivity while minimatch (used in findEmptyDirectories) was case-sensitive by default. The implementation is consistent across all file searching functions and the tests have been appropriately updated to reflect this change.

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.

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

267-296: Test assertions correctly updated; consider adding a behavioral regression test for the bug.

The two updated expect.objectContaining / toMatchObject assertions correctly verify that caseSensitiveMatch: true is forwarded to globby. However, the test suite has no case that demonstrates the actual bug fix — i.e., that a BUILD file is not excluded when build/** (or **/build/**) is among the ignore patterns. Without a dedicated test, a future refactor that reverts or weakens the option would silently re-introduce the regression.

Consider adding a test like:

test('should not exclude uppercase BUILD files when build/** is in ignore patterns', async () => {
  const mockConfig = createMockConfig({
    include: ['**/*'],
    ignore: {
      useGitignore: false,
      useDefaultPatterns: false,
      // Simulate the default `build/**` ignore pattern
      customPatterns: ['build/**'],
    },
  });

  // Globby with caseSensitiveMatch: true should NOT exclude BUILD files
  vi.mocked(globby).mockResolvedValue(['src/BUILD', 'BUILD']);

  const result = await searchFiles('/mock/root', mockConfig);

  expect(result.filePaths).toContain('src/BUILD');
  expect(result.filePaths).toContain('BUILD');
  expect(globby).toHaveBeenCalledWith(
    expect.anything(),
    expect.objectContaining({ caseSensitiveMatch: true }),
  );
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/core/file/fileSearch.test.ts` around lines 267 - 296, The test suite
lacks a behavioral regression test proving that searchFiles forwards
caseSensitiveMatch to globby so uppercase filenames like BUILD aren't excluded
by ignore patterns such as "build/**"; add a new test in
tests/core/file/fileSearch.test.ts that calls searchFiles with a mockConfig
whose ignore.customPatterns includes 'build/**' (and
useGitignore/useDefaultPatterns false), mock globby to resolve
['src/BUILD','BUILD'], call await searchFiles('/mock/root', mockConfig), assert
the returned result.filePaths contains both 'src/BUILD' and 'BUILD', and assert
globby was called with expect.objectContaining({ caseSensitiveMatch: true }) so
the behavior of searchFiles (the function under test) is explicitly verified.
src/core/file/fileSearch.ts (1)

306-320: Add an inline comment explaining why caseSensitiveMatch: true is set explicitly.

caseSensitiveMatch already defaults to true in fast-glob, so without a comment, a future maintainer may read this as noise and remove it. The motivation — preventing the default build/** ignore pattern from matching Pants BUILD files on macOS case-insensitive (HFS+/APFS) filesystems — should be documented inline.

Additionally, note that caseSensitiveMatch: true only governs the ignore: array patterns (processed by micromatch). The gitignore: true code path uses a separate parsing mechanism (the ignore npm module) and is not affected by this option, so case sensitivity for .gitignore-sourced patterns remains OS/git-controlled. This is not a new problem, but worth a brief note in the comment.

✏️ Suggested comment
-  caseSensitiveMatch: true,
+  // Force case-sensitive pattern matching regardless of OS filesystem case sensitivity.
+  // Without this, on macOS (HFS+/APFS case-insensitive), the default ignore pattern
+  // `build/**` would incorrectly exclude Pants `BUILD` files. Although fast-glob defaults
+  // to true, we set it explicitly to document the intent and prevent accidental removal.
+  // Note: this only affects patterns in the `ignore` array (via micromatch); patterns
+  // sourced from .gitignore files are handled separately and are not affected by this option.
+  caseSensitiveMatch: true,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/file/fileSearch.ts` around lines 306 - 320, Add an inline comment
above the caseSensitiveMatch: true setting in createBaseGlobbyOptions explaining
that we explicitly set caseSensitiveMatch to true to avoid glob ignore patterns
like "build/**" matching files named BUILD on case-insensitive macOS filesystems
(HFS+/APFS), and also note that this option only affects patterns passed via the
ignore array (micromatch) and does not change case handling for gitignore=true
(which is handled by the ignore npm module and remains OS/git-controlled).
Ensure the comment references caseSensitiveMatch and clarifies the distinction
from the gitignore code path so future maintainers won't remove this explicit
setting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/core/file/fileSearch.ts`:
- Around line 306-320: Add an inline comment above the caseSensitiveMatch: true
setting in createBaseGlobbyOptions explaining that we explicitly set
caseSensitiveMatch to true to avoid glob ignore patterns like "build/**"
matching files named BUILD on case-insensitive macOS filesystems (HFS+/APFS),
and also note that this option only affects patterns passed via the ignore array
(micromatch) and does not change case handling for gitignore=true (which is
handled by the ignore npm module and remains OS/git-controlled). Ensure the
comment references caseSensitiveMatch and clarifies the distinction from the
gitignore code path so future maintainers won't remove this explicit setting.

In `@tests/core/file/fileSearch.test.ts`:
- Around line 267-296: The test suite lacks a behavioral regression test proving
that searchFiles forwards caseSensitiveMatch to globby so uppercase filenames
like BUILD aren't excluded by ignore patterns such as "build/**"; add a new test
in tests/core/file/fileSearch.test.ts that calls searchFiles with a mockConfig
whose ignore.customPatterns includes 'build/**' (and
useGitignore/useDefaultPatterns false), mock globby to resolve
['src/BUILD','BUILD'], call await searchFiles('/mock/root', mockConfig), assert
the returned result.filePaths contains both 'src/BUILD' and 'BUILD', and assert
globby was called with expect.objectContaining({ caseSensitiveMatch: true }) so
the behavior of searchFiles (the function under test) is explicitly verified.

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.

fix(ignore): BUILD files incorrectly ignored on case-insensitive file systems (macOS)

1 participant