Add documentation for negated ignored files and add a test for it as well
This commit is contained in:
parent
f781b1b9d3
commit
d5f1200ed6
2 changed files with 27 additions and 0 deletions
|
@ -1306,6 +1306,15 @@ If you want to ignore every file under the directory where you put your rustfmt.
|
|||
ignore = ["/"]
|
||||
```
|
||||
|
||||
If you want to allow specific paths that would otherwise be ignored, prefix those paths with a `!`:
|
||||
|
||||
```toml
|
||||
ignore = ["bar_dir/*", "!bar_dir/*/what.rs"]
|
||||
```
|
||||
|
||||
In this case, all files under `bar_dir` will be ignored, except files like `bar_dir/sub/what.rs`
|
||||
or `bar_dir/another/what.rs`.
|
||||
|
||||
## `imports_indent`
|
||||
|
||||
Indent style of imports
|
||||
|
|
|
@ -49,4 +49,22 @@ mod test {
|
|||
assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz.rs"))));
|
||||
assert!(!ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/bar.rs"))));
|
||||
}
|
||||
|
||||
#[nightly_only_test]
|
||||
#[test]
|
||||
fn test_negated_ignore_path_set() {
|
||||
use crate::config::{Config, FileName};
|
||||
use crate::ignore_path::IgnorePathSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
let config = Config::from_toml(
|
||||
r#"ignore = ["foo.rs", "bar_dir/*", "!bar_dir/*/what.rs"]"#,
|
||||
Path::new(""),
|
||||
)
|
||||
.unwrap();
|
||||
let ignore_path_set = IgnorePathSet::from_ignore_list(&config.ignore()).unwrap();
|
||||
assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/what.rs"))));
|
||||
assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz/a.rs"))));
|
||||
assert!(!ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz/what.rs"))));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue