diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2020-02-27 15:52:09 -0500 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2020-02-27 15:52:09 -0500 |
| commit | cac4eeee24b8e17540dfbc28d31f39a732112118 (patch) | |
| tree | a1e5f324ab44a823cc7b9b051595d4dd12cd2aaa /src/bootstrap | |
| parent | 49c68bd53f90e375bfb3cbba8c1c67a9e0adb9c0 (diff) | |
| download | rust-cac4eeee24b8e17540dfbc28d31f39a732112118.tar.gz rust-cac4eeee24b8e17540dfbc28d31f39a732112118.zip | |
Ignore untracked paths when running `rustfmt` on repository.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/format.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 6e5e3fe07e7..a4acb14ee4b 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -1,7 +1,7 @@ //! Runs rustfmt on the repository. use crate::Build; -use build_helper::t; +use build_helper::{output, t}; use ignore::WalkBuilder; use std::path::Path; use std::process::Command; @@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) { for ignore in rustfmt_config.ignore { ignore_fmt.add(&format!("!{}", ignore)).expect(&ignore); } + let untracked_paths_output = output( + Command::new("git").arg("status").arg("--porcelain").arg("--untracked-files=normal"), + ); + let untracked_paths = untracked_paths_output + .lines() + .filter(|entry| entry.starts_with("??")) + .map(|entry| entry.split(" ").nth(1).expect("every git status entry should list a path")); + for untracked_path in untracked_paths { + eprintln!("skip untracked path {} during rustfmt invocations", untracked_path); + ignore_fmt.add(&format!("!{}", untracked_path)).expect(&untracked_path); + } let ignore_fmt = ignore_fmt.build().unwrap(); let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| { |
