mirror of https://github.com/astral-sh/ruff
Include per-file ignore matches in debug logging (#2376)
This commit is contained in:
parent
00495e8620
commit
6051a0c1c8
26
src/fs.rs
26
src/fs.rs
|
|
@ -1,8 +1,10 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
use log::debug;
|
||||||
use path_absolutize::{path_dedot, Absolutize};
|
use path_absolutize::{path_dedot, Absolutize};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
|
|
@ -34,10 +36,28 @@ pub(crate) fn ignores_from_path<'a>(
|
||||||
let (file_path, file_basename) = extract_path_names(path)?;
|
let (file_path, file_basename) = extract_path_names(path)?;
|
||||||
Ok(pattern_code_pairs
|
Ok(pattern_code_pairs
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(absolute, basename, _)| {
|
.filter_map(|(absolute, basename, codes)| {
|
||||||
basename.is_match(file_basename) || absolute.is_match(file_path)
|
if basename.is_match(file_basename) {
|
||||||
|
debug!(
|
||||||
|
"Adding per-file ignores for {:?} due to basename match on {:?}: {:?}",
|
||||||
|
path,
|
||||||
|
basename.deref().glob().regex(),
|
||||||
|
&**codes
|
||||||
|
);
|
||||||
|
return Some(codes.iter());
|
||||||
|
}
|
||||||
|
if absolute.is_match(file_path) {
|
||||||
|
debug!(
|
||||||
|
"Adding per-file ignores for {:?} due to absolute match on {:?}: {:?}",
|
||||||
|
path,
|
||||||
|
absolute.deref().glob().regex(),
|
||||||
|
&**codes
|
||||||
|
);
|
||||||
|
return Some(codes.iter());
|
||||||
|
}
|
||||||
|
None
|
||||||
})
|
})
|
||||||
.flat_map(|(_, _, codes)| codes.iter())
|
.flatten()
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue