Skip to content

Commit 620efed

Browse files
committed
x fmt: Only check modified files locally
Previously, `x fmt` would only format modified files, while `x fmt .` and `x fmt --check` would still look at all files. After this change, `x fmt --check` only looks at modified files locally. I feel pretty confident in this change - other than #106261, no one has reported bugs in `get_modified_rs_files` since it was added in #105702.
1 parent 14c54b6 commit 620efed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bootstrap/format.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::builder::Builder;
44
use crate::util::{output, program_out_of_date, t};
5+
use build_helper::ci::CiEnv;
56
use build_helper::git::get_git_modified_files;
67
use ignore::WalkBuilder;
78
use std::collections::VecDeque;
@@ -156,7 +157,10 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
156157
// preventing the latter from being formatted.
157158
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
158159
}
159-
if !check && paths.is_empty() {
160+
// Only check modified files locally to speed up runtime.
161+
// We still check all files in CI to avoid bugs in `get_modified_rs_files` letting regressions slip through;
162+
// we also care about CI time less since this is still very fast compared to building the compiler.
163+
if !CiEnv::is_ci() && paths.is_empty() {
160164
match get_modified_rs_files(build) {
161165
Ok(Some(files)) => {
162166
for file in files {

0 commit comments

Comments
 (0)