expand patterns in GlobEntry
This commit is contained in:
parent
6c7ba2505e
commit
8d78912e0c
1 changed files with 21 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::parser::Extractor;
|
||||
use crate::scanner::detect_sources::DetectSources;
|
||||
use bexpand::Expression;
|
||||
use bstr::ByteSlice;
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use glob::fast_glob;
|
||||
|
|
@ -217,6 +218,26 @@ impl Scanner {
|
|||
return;
|
||||
}
|
||||
|
||||
// Expand glob patterns and create new `GlobEntry` instances for each expanded pattern.
|
||||
let sources = sources
|
||||
.iter()
|
||||
.flat_map(|source| {
|
||||
let expression: Result<Expression, _> = source.pattern[..].try_into();
|
||||
let Ok(expression) = expression else {
|
||||
return vec![source.clone()];
|
||||
};
|
||||
|
||||
expression
|
||||
.into_iter()
|
||||
.filter_map(|expanded_pattern| expanded_pattern.map(|x| x.into()).ok())
|
||||
.map(move |pattern| GlobEntry {
|
||||
base: source.base.clone(),
|
||||
pattern,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Partition sources into sources that should be promoted to auto source detection and
|
||||
// sources that should be resolved as globs.
|
||||
let (auto_sources, glob_sources): (Vec<_>, Vec<_>) = sources.iter().partition(|source| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue