From 33a2087026bfc04b1463bed4fb4bf24c342ca736 Mon Sep 17 00:00:00 2001 From: Fabio Forni Date: Tue, 26 Mar 2024 15:46:10 +0100 Subject: [PATCH] crates/triggers: Adapt code to the new fnmatch API --- crates/triggers/src/format.rs | 8 ++++---- crates/triggers/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/triggers/src/format.rs b/crates/triggers/src/format.rs index c3fdbcf1..09f5a0e5 100644 --- a/crates/triggers/src/format.rs +++ b/crates/triggers/src/format.rs @@ -29,14 +29,14 @@ impl Handler { match self { Handler::Run { run, args } => { let mut run = run.clone(); - for (key, value) in &with_match.variables { + for (key, value) in &with_match.groups { run = run.replace(&format!("$({key})"), value); } let args = args .iter() .map(|a| { let mut a = a.clone(); - for (key, value) in &with_match.variables { + for (key, value) in &with_match.groups { a = a.replace(&format!("$({key})"), value); } a @@ -99,9 +99,9 @@ mod tests { let (pattern, _) = trigger.paths.iter().next().expect("Missing path entry"); let result = pattern - .match_path("/usr/lib/modules/6.6.7-267.current/kernel") + .matches("/usr/lib/modules/6.6.7-267.current/kernel") .expect("Couldn't match path"); - let version = result.variables.get("version").expect("Missing kernel version"); + let version = result.groups.get("version").expect("Missing kernel version"); assert_eq!(version, "6.6.7-267.current", "Wrong kernel version match"); eprintln!("trigger: {trigger:?}"); eprintln!("match: {result:?}"); diff --git a/crates/triggers/src/lib.rs b/crates/triggers/src/lib.rs index 465331db..85c8fb5c 100644 --- a/crates/triggers/src/lib.rs +++ b/crates/triggers/src/lib.rs @@ -73,7 +73,7 @@ impl<'a> Collection<'a> { let results = paths.into_iter().flat_map(|p| { self.handlers .iter() - .filter_map(move |h| h.pattern.match_path(&p).map(|m| (h.id.clone(), m, h.handler.clone()))) + .filter_map(move |h| h.pattern.matches(&p).map(|m| (h.id.clone(), m, h.handler.clone()))) }); self.hits.extend(results); }