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 May 10, 2024
1 parent 4a62f68 commit 703e701
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 @@ -38,14 +38,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 @@ -108,9 +108,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 @@ -66,7 +66,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(), h.handler.compiled(&m))))
.filter_map(move |h| h.pattern.matches(&p).map(|m| (h.id.clone(), h.handler.compiled(&m))))
});

for (id, handler) in results {
Expand Down

0 comments on commit 703e701

Please sign in to comment.