Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/diffguard-core/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub enum PathFilterError {
glob: String,
source: globset::Error,
},
#[error("failed to build path filter glob set: {source}")]
GlobSetBuild { source: globset::Error },
}

/// Run a policy check over a unified diff text.
Expand Down Expand Up @@ -265,7 +267,8 @@ fn compile_filter_globs(globs: &[String]) -> Result<GlobSet, PathFilterError> {
})?;
b.add(glob);
}
Ok(b.build().expect("globset build should succeed"))
b.build()
.map_err(|source| PathFilterError::GlobSetBuild { source })
}

/// Filter a rule based on tag criteria in the plan.
Expand Down Expand Up @@ -436,6 +439,9 @@ mod tests {
let err = compile_filter_globs(&["[".to_string()]).unwrap_err();
match err {
PathFilterError::InvalidGlob { glob, .. } => assert_eq!(glob, "["),
PathFilterError::GlobSetBuild { .. } => {
panic!("expected InvalidGlob, got GlobSetBuild")
}
}
}

Expand Down
Loading