-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pattern with wildcard and globstar can't match correctly when using glob_match
#6668
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
There are some changes in test cases compared to |
@JSerFeng I believe we can make use Link to the test cases: https://github.com/SyMind/glob-test |
need a benchmark |
Is the |
I haven't replied to this PR for a long time because I have encountered a serious issue related to ExamplesSimple MatchNote that simple matching does not support use fast_glob::glob_match;
let glob = "some/**/n*d[k-m]e?txt";
let path = "some/a/bigger/path/to/the/crazy/needle.txt";
assert!(glob_match(glob, path)); Brace ExpansionBrace expansion is supported by using use fast_glob::glob_match_with_brace;
let glob = "some/**/{the,crazy}/?*.{png,txt}";
let path = "some/a/bigger/path/to/the/crazy/needle.txt";
assert!(glob_match_with_brace(glob, path)); Multi-Pattern MatchingYou can build a matcher like use fast_glob::Glob;
// let mut glob = Glob::new(glob);
let mut glob = Glob::default();
assert!(glob.add("*.txt"));
assert!(glob.is_match("name.txt")); BenchmarkTest Case 1const GLOB: &'static str = "some/**/n*d[k-m]e?txt";
const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
Test Case 2const GLOB: &'static str = "some/**/{tob,crazy}/?*.{png,txt}";
const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
Q&AWhy not use the more efficient
|
|
Is there anything else I need to do? @LingyuCoder |
|
LGTM |
@shulaoda the performance of |
This is because it needs to support complex I believe that priority should be given to ensuring the soundness of the functionality, as a certain degree of performance loss is inevitable. |
Perhaps we should give up on |
also fix #7100 |
!bench |
📝 Benchmark detail: Open
|
Can you provide an option to control whether to enable complex brace expansion or not. If it is not enabled, only the same processing logic as glob_match will be used, so as to have better performance. |
I can only control it to use This is because there are many issues with the data structure of |
Is this switch automatic or configuration-driven? |
Please wait, I will show you more benchmark information. |
Test Case 1const GLOB: &'static str = "some/**/n*d[k-m]e?txt";
const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
Test Case 2const GLOB: &'static str = "some/**/{tob,crazy}/?*.{png,txt}";
const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
Test Case 3const GLOB: &'static str = "some/**/{a,b,c}{d,e,f,g,h,i}{{gg,gger},r}/needle.{png,txt}{a,b}{c,d}{e,f}";
const PATH: &'static str = "some/a/b/c/bigger/needle.txtbdf";
Test Case 4const GLOB: &'static str = "some/**/{b,c}/{**/*?txt,needle.txt}";
const PATH: &'static str = "some/a/b/c/bigger/needle.txt";
Test Case 5const GLOB: &'static str = "some/**/{the,crazy}/?*.{png,txt}";
const PATH: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
|
Thanks for your great work. |
Summary
Fixed #6245 and #6613
To solve this problem, I have invested a lot of effort in understanding the
glob_match
. Due to the original author not maintaining it for a long time, I have republished thefast_glob
.Using
fast_glob
, you can get:The original intention of
fast_glob
is only to promptly fix the first issue mentioned above.Checklist