Skip to main content

matches_pattern

Function matches_pattern 

Source
pub fn matches_pattern(
    files: &[PathBuf],
    project_root: &Path,
    pattern: &str,
) -> bool
Expand description

Check if any of the given files match a pattern.

Supports two matching modes:

  • Simple paths: Patterns without wildcards (*, ?, [) are treated as path prefixes. For example, "crates" matches "crates/foo/bar.rs".
  • Glob patterns: Patterns with wildcards use glob matching.

§Arguments

  • files - Changed file paths (typically repo-relative from git diff)
  • project_root - The project root for normalizing paths
  • pattern - The input pattern to match against

§Returns

true if any file matches the pattern