Skip to content

Fix gitignore patterns with ** glob being silently dropped#5

Open
avarayr wants to merge 1 commit intoglommer:mainfrom
avarayr:fix/gitignore-glob-patterns
Open

Fix gitignore patterns with ** glob being silently dropped#5
avarayr wants to merge 1 commit intoglommer:mainfrom
avarayr:fix/gitignore-glob-patterns

Conversation

@avarayr
Copy link
Copy Markdown
Contributor

@avarayr avarayr commented Feb 26, 2026

Summary

  • loadIgnorePatterns was skipping any line containing *, so **/name/ patterns were silently ignored
  • Extract directory name from **/name patterns and add to the ignore set
  • Add walker tests

Copilot AI review requested due to automatic review settings February 26, 2026 22:28
Copy link
Copy Markdown

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.

Pull request overview

This pull request fixes a bug where gitignore patterns containing ** glob syntax (like **/Pods/ and **/vendor/) were being silently ignored. The fix extracts directory names from **/name patterns and adds them to the ignore set, while intentionally skipping more complex glob patterns that aren't supported by the simplified directory-name-only matching approach.

Changes:

  • Enhanced loadIgnorePatterns function to handle **/name and **/name/ patterns by extracting the directory name
  • Added comprehensive test suite for gitignore pattern handling in walker functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/scan/walker.ts Modified loadIgnorePatterns to extract directory names from **/name patterns using regex, while still skipping other glob patterns
test/walker.test.ts Added new test file with 5 test cases covering plain patterns, **/name patterns with/without trailing slashes, and verification that unsupported glob patterns are skipped

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/walker.test.ts
Comment on lines +60 to +69
test("*.ext glob patterns are still skipped", async () => {
const tmp = setupFixture("*.log\n", [], { "app.ts": "export const x = 1", "debug.log": "some log" })
try {
const { files } = await scanDirectory(tmp)
const names = files.map(f => f.relPath)
expect(names).toContain("app.ts")
} finally {
cleanupFixture()
}
})
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The test description says "*.ext glob patterns are still skipped" but doesn't verify the actual behavior of debug.log. The test should explicitly check that debug.log is included in the results (not filtered out), since *.log patterns are intentionally not processed. Consider adding: expect(names).toContain("debug.log") to make the test's intent clearer and verify the expected behavior.

Copilot uses AI. Check for mistakes.
Comment thread test/walker.test.ts
Comment on lines +35 to +46
test("**/name/ patterns are ignored", async () => {
const tmp = setupFixture("**/Pods/\n**/vendor/\n", ["Pods", "vendor"], { "Pods/lib.ts": "export const a = 1", "vendor/dep.ts": "export const b = 2", "app.ts": "export const c = 3" })
try {
const { files } = await scanDirectory(tmp)
const names = files.map(f => f.relPath)
expect(names).toContain("app.ts")
expect(names).not.toContain("Pods/lib.ts")
expect(names).not.toContain("vendor/dep.ts")
} finally {
cleanupFixture()
}
})
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Consider adding a test case for nested directories to verify that **/Pods/ correctly ignores directories like ios/Pods or app/vendor, not just root-level directories. This would better validate that the pattern matching works at any directory depth, which is the expected behavior of ** patterns in gitignore.

Copilot uses AI. Check for mistakes.
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