feat(tools): add convertGitignorePatternToMinimatch utility#1
Draft
feat(tools): add convertGitignorePatternToMinimatch utility#1
Conversation
Agent-Logs-Url: https://github.com/GoodbyeNJN/utils/sessions/67767ecc-444f-4a26-96eb-3991a01d668b Co-authored-by: GoodbyeNJN <[email protected]>
Agent-Logs-Url: https://github.com/GoodbyeNJN/utils/sessions/67767ecc-444f-4a26-96eb-3991a01d668b Co-authored-by: GoodbyeNJN <[email protected]>
Copilot created this pull request from a session on behalf of
GoodbyeNJN
May 1, 2026 16:22
View session
Owner
|
@copilot 还需要做一些改动:
|
… whitespace, remove package-lock.json Agent-Logs-Url: https://github.com/GoodbyeNJN/utils/sessions/de5a6192-5fab-484f-9ef4-568596da69cc Co-authored-by: GoodbyeNJN <[email protected]>
Author
Done in commit e011ecc:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Owner
|
@copilot 我已在防火墙规则中放行了所有针对 github.com 域名的请求,现在你可以按需重试被拦截的操作。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a utility to convert gitignore patterns into minimatch/micromatch-compatible glob patterns, covering all rules from the official git documentation.
Changes
src/tools/gitignore.tsconvertGitignorePatternToMinimatch(pattern): string | null— returnsnullfor blank lines and comments, otherwise produces a valid minimatch/micromatch patternConversion rules applied:
""/" "null"# comment"null"\\#file"/"\\!file""**/#file"/"**/!file""foo""**/foo""/foo""foo""foo/bar""foo/bar""foo/""**/foo/**""/foo/""foo/**""!foo""!**/foo""**/foo","a/**/b"Trailing whitespace is stripped character-by-character from the right. A trailing space/tab preceded by an odd number of backslashes is preserved (escaped); all others are stripped. This correctly handles
\\+ space (double backslash escapes itself, not the space).tests/tools/gitignore.test.tsnode-ignoreis used as the source-of-truth baseline to determine whether a given path should be ignored by the pattern. The pattern is then converted withconvertGitignorePatternToMinimatchand bothminimatchandmicromatchare asserted to produce the same match result.**///**/globstar patterns.src/tools/index.tsconvertGitignorePatternToMinimatchfrom the root package entry point.Dependencies
ignore,minimatch,micromatch, and@types/micromatchas devDependencies for use in tests.