Feature: Add file/directory exclusion feature with glob pattern support #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The motivation of the PR is in many repositories; we don't want to include some files, e.g., tests*)
and it may also include a file that would be either broken or meaningless. However, all these files will not only affect the processing time of pyright-scip, but also will cause abortion. One example I showed below is the failed log while I process the sympy repo. I also attached the success log after applying our new
excludepattern.Summary
This PR adds the ability to exclude files and directories from SCIP indexing using command-line flags or a configuration file. The exclusion feature supports both exact paths and glob patterns (e.g.,
test_*), and works as a filter that gracefully handles non-matching patterns without errors.Changes Made
1. MainCommand.ts
exclude?: string[]toIndexOptionsinterfaceexcludeConfig?: stringtoIndexOptionsinterface--exclude <paths...>flag to accept multiple file/directory paths--exclude-config <file>flag to accept a config file with exclusion paths2. indexer.ts
import { minimatch } from 'minimatch'for glob pattern matchingtargetOnlyfiltering (lines 122-179)--excludeflag--exclude-configis provideddir*,file*,tests/**, etc.3. package.json
minimatchdependency for glob pattern matchingUsage
.scipignore):*Benefits
--target-onlyflagTesting
The feature can be tested by:
Using
--excludewith exact pathsUsing
--excludewith glob patterns liketest_*Using
--exclude-configwith a file containing mixed patterns and commentsVerifying that non-matching patterns don't cause errors
Log when directly indexing the sympy
Log after the exclude feature applied