Skip to content

Commit 254b708

Browse files
committed
newglob
1 parent 3f9264e commit 254b708

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
3838
anyhow = "1.0.65"
3939
thiserror = "1.0.35"
4040
linked-hash-map = "0.5"
41-
globset = "0.4.8"
41+
globset = "0.4.14"
4242
commands = "0.0.5"
4343
env_logger = "0.10"
4444
log = { version = "~0.4", features = ["std"] }

src/patch/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod patch_cli;
22

3-
use globset::Glob;
43
use std::fs::File;
54
use std::io::{Read, Write};
65
use std::path::{Path, PathBuf};
@@ -248,19 +247,23 @@ fn matchname(name: &str, spec: &str) -> bool {
248247
matchsubspec(name, spec).is_some()
249248
}
250249

250+
fn newglob(spec: &str) -> globset::GlobMatcher {
251+
globset::Glob::new(spec).unwrap().compile_matcher()
252+
}
253+
251254
/// If a name matches a specification, return the first sub-specification that it matches
252255
fn matchsubspec<'a>(name: &str, spec: &'a str) -> Option<&'a str> {
253256
if spec.starts_with('_') {
254257
return None;
255258
}
256259
if spec.contains('{') {
257-
let glob = Glob::new(spec).unwrap().compile_matcher();
260+
let glob = newglob(spec);
258261
if glob.is_match(name) {
259262
return Some(spec);
260263
}
261264
} else {
262265
for subspec in spec.split(',') {
263-
let glob = Glob::new(subspec).unwrap().compile_matcher();
266+
let glob = newglob(subspec);
264267
if glob.is_match(name) {
265268
return Some(subspec);
266269
}

0 commit comments

Comments
 (0)