about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2023-03-05 08:16:32 -0600
committerJoshua Nelson <github@jyn.dev>2023-03-05 08:22:55 -0600
commit620efed932766b4cd516a26205fe47f51f54f911 (patch)
treea1f3501fc3b4ec529351fa63cf82ecf65aaa747d /src/bootstrap
parent14c54b637b18f74680d0c0441216714b5e9c150d (diff)
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
https://github.com/rust-lang/rust/issues/106261, no one has reported
bugs in `get_modified_rs_files` since it was added in
https://github.com/rust-lang/rust/pull/105702.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/format.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs
index 6d5753e8a6d..36372512562 100644
--- a/src/bootstrap/format.rs
+++ b/src/bootstrap/format.rs
@@ -2,6 +2,7 @@
 
 use crate::builder::Builder;
 use crate::util::{output, program_out_of_date, t};
+use build_helper::ci::CiEnv;
 use build_helper::git::get_git_modified_files;
 use ignore::WalkBuilder;
 use std::collections::VecDeque;
@@ -156,7 +157,10 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
                 // preventing the latter from being formatted.
                 ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
             }
-            if !check && paths.is_empty() {
+            // Only check modified files locally to speed up runtime.
+            // We still check all files in CI to avoid bugs in `get_modified_rs_files` letting regressions slip through;
+            // we also care about CI time less since this is still very fast compared to building the compiler.
+            if !CiEnv::is_ci() && paths.is_empty() {
                 match get_modified_rs_files(build) {
                     Ok(Some(files)) => {
                         for file in files {