mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
File exclusion: Reduce code duplication (#8336)
This commit is contained in:
parent
221f7cd932
commit
1f2d4f3ee1
2 changed files with 7 additions and 5 deletions
|
@ -161,7 +161,7 @@ impl FilePattern {
|
|||
|
||||
// Add basename path.
|
||||
if !pattern.contains(std::path::MAIN_SEPARATOR) {
|
||||
builder.add(Glob::from_str(&pattern)?);
|
||||
builder.add(Glob::new(&pattern)?);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -547,15 +547,17 @@ fn is_file_excluded(
|
|||
|
||||
/// Return `true` if the given file should be ignored based on the exclusion
|
||||
/// criteria.
|
||||
#[inline]
|
||||
pub fn match_exclusion<P: AsRef<Path>, R: AsRef<Path>>(
|
||||
file_path: P,
|
||||
file_basename: R,
|
||||
exclusion: &GlobSet,
|
||||
) -> bool {
|
||||
if exclusion.is_empty() {
|
||||
return false;
|
||||
}
|
||||
exclusion.is_match(file_path) || exclusion.is_match(file_basename)
|
||||
match_candidate_exclusion(
|
||||
&Candidate::new(file_path.as_ref()),
|
||||
&Candidate::new(file_basename.as_ref()),
|
||||
exclusion,
|
||||
)
|
||||
}
|
||||
|
||||
/// Return `true` if the given candidates should be ignored based on the exclusion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue