-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the enhancement
The default globbing technique investigates all paths, even ones that have already been invalidated by negated matchers:
toolkit/packages/glob/src/internal-pattern-helper.ts
Lines 59 to 81 in 1cc56db
/** | |
* Matches the patterns against the path | |
*/ | |
export function match(patterns: Pattern[], itemPath: string): MatchKind { | |
let result: MatchKind = MatchKind.None | |
for (const pattern of patterns) { | |
if (pattern.negate) { | |
result &= ~pattern.match(itemPath) | |
} else { | |
result |= pattern.match(itemPath) | |
} | |
} | |
return result | |
} | |
/** | |
* Checks whether to descend further into the directory | |
*/ | |
export function partialMatch(patterns: Pattern[], itemPath: string): boolean { | |
return patterns.some(x => !x.negate && x.partialMatch(itemPath)) | |
} |
This differs from Git's globbing technique used in the
.gitignore
files here:
It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
This is unintuitive because many developers are already familiar with Git's globbing style and can inadvertently introduce performance problems by including arbitrary folders and trying (and failing) to exclude certain large directories.
Additional information
limjh16/jekyll-action-ts#3 (comment) describes a significant performance penalty from searching everywhere for a certain file name.