Skip to content

Commit

Permalink
crates/triggers: Adapt code to the new fnmatch API
Browse files Browse the repository at this point in the history
  • Loading branch information
livingsilver94 committed Mar 26, 2024
1 parent b7069e6 commit 33a2087
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/triggers/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:?}");
Expand Down
2 changes: 1 addition & 1 deletion crates/triggers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 33a2087

Please sign in to comment.