Skip to content

Fix ExcludedFolders configuration not working in directory scanning#245

Merged
239573049 merged 2 commits intomainfrom
copilot/fix-244
Aug 28, 2025
Merged

Fix ExcludedFolders configuration not working in directory scanning#245
239573049 merged 2 commits intomainfrom
copilot/fix-244

Conversation

Copy link
Contributor

Copilot AI commented Aug 28, 2025

The DocumentOptions.ExcludedFolders configuration was not working properly during repository scanning. Users could configure folder exclusions, but they were completely ignored during the directory scanning process.

Problem

The DocumentsHelper.GetIgnoreFiles() method only included DocumentOptions.ExcludedFiles in the ignore patterns, but never added DocumentOptions.ExcludedFolders. This meant that:

  1. Configured folder exclusions like node_modules, build, dist were ignored
  2. The ScanDirectory method would still process and include files from supposedly excluded folders
  3. When no .gitignore file existed, both ExcludedFiles and ExcludedFolders were completely ignored

Solution

Modified the GetIgnoreFiles() method to always include both DocumentOptions.ExcludedFiles and DocumentOptions.ExcludedFolders in the ignore patterns:

// Before: Only ExcludedFiles were included
ignoreFiles.AddRange(DocumentOptions.ExcludedFiles);

// After: Both ExcludedFiles and ExcludedFolders are included
ignoreFiles.AddRange(DocumentOptions.ExcludedFiles);
ignoreFiles.AddRange(DocumentOptions.ExcludedFolders);

The existing ScanDirectory method already has robust pattern matching logic that supports:

  • Exact folder names (node_modules)
  • Wildcard patterns (*.tmp)
  • Directory-specific patterns (build/)
  • Case-insensitive matching

This fix leverages that existing infrastructure without requiring any changes to the directory filtering logic.

Impact

  • Backward Compatible: All existing functionality continues to work exactly as before
  • Minimal Change: Only 9 insertions, 7 deletions
  • Comprehensive: Now supports all the same pattern types for folders as were already supported for files
  • Edge Case Fixed: Exclusions now work even when no .gitignore file exists

Example usage that now works properly:

DocumentOptions.ExcludedFolders = new[] { "node_modules", "build", "dist", "*.tmp" };
// Directory scanning will now properly exclude these folders

Fixes #244.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Aug 28, 2025

@239573049 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: 239573049 <61819790+239573049@users.noreply.github.com>
Copilot AI changed the title [WIP] 文件夹排除不起作用 Fix ExcludedFolders configuration not working in directory scanning Aug 28, 2025
Copilot AI requested a review from 239573049 August 28, 2025 02:08
@239573049 239573049 marked this pull request as ready for review August 28, 2025 06:04
Copilot AI review requested due to automatic review settings August 28, 2025 06:04
@239573049 239573049 merged commit 8315396 into main Aug 28, 2025
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.

Pull Request Overview

This PR fixes a configuration bug where the DocumentOptions.ExcludedFolders setting was completely ignored during repository scanning, causing users' folder exclusion configurations to be ineffective.

  • Modified GetIgnoreFiles() method to include both excluded files and excluded folders in ignore patterns
  • Fixed logic to ensure exclusions work even when no .gitignore file exists
  • Leveraged existing pattern matching infrastructure in ScanDirectory method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

文件夹排除不起作用

3 participants