Gracefully handle models searching for empty glob (#27370)
Sometimes we've seen models provide an empty string for the path search glob. This assumes they meant "*" when that happens. Separately, this also removes an unnecessary `clone` of a `String`. Release Notes: - N/A
This commit is contained in:
parent
430814c0a9
commit
6b7167a32d
3 changed files with 11 additions and 6 deletions
|
@ -377,10 +377,10 @@ impl PartialEq for PathMatcher {
|
|||
impl Eq for PathMatcher {}
|
||||
|
||||
impl PathMatcher {
|
||||
pub fn new(globs: &[String]) -> Result<Self, globset::Error> {
|
||||
pub fn new(globs: impl IntoIterator<Item = impl AsRef<str>>) -> Result<Self, globset::Error> {
|
||||
let globs = globs
|
||||
.iter()
|
||||
.map(|glob| Glob::new(glob))
|
||||
.into_iter()
|
||||
.map(|as_str| Glob::new(as_str.as_ref()))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let sources = globs.iter().map(|glob| glob.glob().to_owned()).collect();
|
||||
let mut glob_builder = GlobSetBuilder::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue