mirror of
https://github.com/numtide/treefmt.git
synced 2024-10-04 04:27:21 +03:00
minor fixes
This commit is contained in:
parent
63f8fdfe3d
commit
609e686d7a
@ -80,9 +80,9 @@ pub fn from_path(file_path: &Path) -> Result<Root> {
|
||||
.and_then(|content| from_string(&content))
|
||||
}
|
||||
|
||||
/// Parses the provide string into a treefmt config object
|
||||
/// Parses the provided string into a treefmt config object
|
||||
pub fn from_string(file_contents: &str) -> Result<Root> {
|
||||
toml::from_str::<Root>(&file_contents).map_err(Error::msg)
|
||||
toml::from_str::<Root>(file_contents).map_err(Error::msg)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -57,7 +57,7 @@ pub fn run_treefmt(
|
||||
// Make sure all the given paths are absolute. Ignore the ones that point outside of the project root.
|
||||
let paths = paths.iter().fold(vec![], |mut sum, path| {
|
||||
let abs_path = expand_path(path, work_dir);
|
||||
if abs_path.starts_with(&tree_root) {
|
||||
if abs_path.starts_with(tree_root) {
|
||||
sum.push(abs_path);
|
||||
} else {
|
||||
warn!(
|
||||
@ -337,7 +337,7 @@ fn print_summary(
|
||||
) {
|
||||
println!(
|
||||
r#"
|
||||
{} files changed in {:.0?} (found {}, matched {}, cache misses {})
|
||||
{} files changed in {:.0?} (found {}, matched {}, cache misses {})
|
||||
"#,
|
||||
reformatted_files,
|
||||
start_time.elapsed(),
|
||||
@ -363,7 +363,7 @@ pub fn run_treefmt_stdin(
|
||||
assert!(path.is_absolute());
|
||||
|
||||
// Make sure all the given paths are absolute. Ignore the ones that point outside of the project root.
|
||||
if !path.starts_with(&tree_root) {
|
||||
if !path.starts_with(tree_root) {
|
||||
return Err(anyhow!(
|
||||
"Ignoring path {}, it is not in the project root",
|
||||
path.display()
|
||||
@ -401,7 +401,7 @@ pub fn run_treefmt_stdin(
|
||||
);
|
||||
|
||||
// Collect all formatters that match the path
|
||||
let formatters: Vec<&Formatter> = formatters.values().filter(|f| f.is_match(&path)).collect();
|
||||
let formatters: Vec<&Formatter> = formatters.values().filter(|f| f.is_match(path)).collect();
|
||||
|
||||
if formatters.is_empty() {
|
||||
warn!("no formatter found for path {:?}", path);
|
||||
|
Loading…
Reference in New Issue
Block a user