@@ -152,13 +152,15 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
152
152
. map ( |entry| {
153
153
entry. split ( ' ' ) . nth ( 1 ) . expect ( "every git status entry should list a path" )
154
154
} ) ;
155
+ let mut untracked_count = 0 ;
155
156
for untracked_path in untracked_paths {
156
157
println ! ( "skip untracked path {untracked_path} during rustfmt invocations" ) ;
157
158
// The leading `/` makes it an exact match against the
158
159
// repository root, rather than a glob. Without that, if you
159
160
// have `foo.rs` in the repository root it will also match
160
161
// against anything like `compiler/rustc_foo/src/foo.rs`,
161
162
// preventing the latter from being formatted.
163
+ untracked_count += 1 ;
162
164
ignore_fmt. add ( & format ! ( "!/{untracked_path}" ) ) . expect ( & untracked_path) ;
163
165
}
164
166
// Only check modified files locally to speed up runtime.
@@ -167,13 +169,28 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
167
169
if !CiEnv :: is_ci ( ) && paths. is_empty ( ) {
168
170
match get_modified_rs_files ( build) {
169
171
Ok ( Some ( files) ) => {
172
+ eprintln ! ( "Found {:?} modified files" , files) ;
170
173
if files. len ( ) <= 10 {
171
174
for file in & files {
172
175
println ! ( "formatting modified file {file}" ) ;
173
176
}
174
- } else {
175
- println ! ( "formatting {} modified files" , files. len( ) ) ;
176
177
}
178
+ let pluralized = |count| if count > 1 { "files" } else { "file" } ;
179
+ let untracked_msg = if untracked_count == 0 {
180
+ "" . to_string ( )
181
+ } else {
182
+ format ! (
183
+ ", skipped {} untracked {}" ,
184
+ untracked_count,
185
+ pluralized( untracked_count) ,
186
+ )
187
+ } ;
188
+ println ! (
189
+ "formatting {} modified {}{}" ,
190
+ files. len( ) ,
191
+ pluralized( files. len( ) ) ,
192
+ untracked_msg
193
+ ) ;
177
194
for file in files {
178
195
ignore_fmt. add ( & format ! ( "/{file}" ) ) . expect ( & file) ;
179
196
}
0 commit comments