File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
//! Runs rustfmt on the repository.
2
2
3
3
use crate :: Build ;
4
- use build_helper:: t ;
4
+ use build_helper:: { output , t } ;
5
5
use ignore:: WalkBuilder ;
6
6
use std:: path:: Path ;
7
7
use std:: process:: Command ;
@@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) {
53
53
for ignore in rustfmt_config. ignore {
54
54
ignore_fmt. add ( & format ! ( "!{}" , ignore) ) . expect ( & ignore) ;
55
55
}
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
+ }
56
67
let ignore_fmt = ignore_fmt. build ( ) . unwrap ( ) ;
57
68
58
69
let rustfmt_path = build. config . initial_rustfmt . as_ref ( ) . unwrap_or_else ( || {
You can’t perform that action at this time.
0 commit comments