File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 11//! Runs rustfmt on the repository.
22
33use crate :: Build ;
4- use build_helper:: t ;
4+ use build_helper:: { output , t } ;
55use ignore:: WalkBuilder ;
66use std:: path:: Path ;
77use std:: process:: Command ;
@@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) {
5353 for ignore in rustfmt_config. ignore {
5454 ignore_fmt. add ( & format ! ( "!{}" , ignore) ) . expect ( & ignore) ;
5555 }
56+ let untracked_paths_output = output (
57+ Command :: new ( "git" ) . arg ( "status" ) . arg ( "--porcelain" ) . arg ( "--untracked-files=normal" ) ,
58+ ) ;
59+ let untracked_paths = untracked_paths_output
60+ . lines ( )
61+ . filter ( |entry| entry. starts_with ( "??" ) )
62+ . map ( |entry| entry. split ( " " ) . nth ( 1 ) . expect ( "every git status entry should list a path" ) ) ;
63+ for untracked_path in untracked_paths {
64+ eprintln ! ( "skip untracked path {} during rustfmt invocations" , untracked_path) ;
65+ ignore_fmt. add ( & format ! ( "!{}" , untracked_path) ) . expect ( & untracked_path) ;
66+ }
5667 let ignore_fmt = ignore_fmt. build ( ) . unwrap ( ) ;
5768
5869 let rustfmt_path = build. config . initial_rustfmt . as_ref ( ) . unwrap_or_else ( || {
You can’t perform that action at this time.
0 commit comments