Skip to content

Commit c286fbb

Browse files
committed
rip out TIDY_PRINT_DIFF
and just always show diffs by default. not sure why you'd want to hide them.
1 parent 264bf6d commit c286fbb

3 files changed

Lines changed: 16 additions & 27 deletions

File tree

src/ci/docker/host-x86_64/tidy/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
3939

4040
# NOTE: intentionally uses python2 for x.py so we can test it still works.
4141
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
42-
ENV SCRIPT="TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
43-
src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck"
42+
ENV SCRIPT="python2.7 ../x.py test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck"

src/etc/pre-push.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ ROOT_DIR="$(git rev-parse --show-toplevel)"
3333
echo "Running pre-push script $ROOT_DIR/x test tidy"
3434

3535
cd "$ROOT_DIR"
36-
# The env var is necessary for printing diffs in py (fmt/lint) and cpp.
37-
TIDY_PRINT_DIFF=1 ./x test tidy \
36+
./x test tidy \
3837
--set build.locked-deps=true \
3938
--extra-checks auto:py,auto:cpp,auto:js
4039
if [ $? -ne 0 ]; then

src/tools/tidy/src/extra_checks/mod.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
//! configuration after a double dash (`--extra-checks=py -- foo.py`)
1111
//! 2. Build configuration based on args/environment:
1212
//! - Formatters by default are in check only mode
13-
//! - If in CI (TIDY_PRINT_DIFF=1 is set), check and print the diff
1413
//! - If `--bless` is provided, formatters may run
1514
//! - Pass any additional config after the `--`. If no files are specified,
1615
//! use a default.
17-
//! 3. Print the output of the given command. If it fails and `TIDY_PRINT_DIFF`
18-
//! is set, rerun the tool to print a suggestion diff (for e.g. CI)
16+
//! 3. Print the output of the given command. If it fails, rerun the tool to print a suggestion
17+
//! diff.
1918
2019
use std::ffi::{OsStr, OsString};
2120
use std::path::{Path, PathBuf};
@@ -206,12 +205,6 @@ fn show_bless_help(mode: &str, action: &str, bless: bool) {
206205
}
207206
}
208207

209-
fn show_diff() -> bool {
210-
let disable_diff =
211-
std::env::var("TIDY_PRINT_DIFF").is_ok_and(|v| v.eq_ignore_ascii_case("false") || v == "0");
212-
!disable_diff
213-
}
214-
215208
fn check_spellcheck(root_path: &Path, outdir: &Path, cargo: &Path, tidy_ctx: &TidyCtx) {
216209
let mut check = tidy_ctx.start_check("extra_checks:spellcheck");
217210

@@ -318,7 +311,7 @@ fn check_python_lint(
318311

319312
let res = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, args);
320313

321-
if res.is_err() && !bless && show_diff() {
314+
if res.is_err() && !bless {
322315
eprintln!("\npython linting failed! Printing diff suggestions:");
323316

324317
let diff_res = run_ruff(
@@ -362,18 +355,16 @@ fn check_python_fmt(
362355
let res = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, &args);
363356

364357
if res.is_err() && !bless {
365-
if show_diff() {
366-
eprintln!("\npython formatting does not match! Printing diff:");
367-
368-
let _ = run_ruff(
369-
root_path,
370-
outdir,
371-
py_path,
372-
&cfg_args,
373-
&file_args,
374-
&["format".as_ref(), "--diff".as_ref()],
375-
);
376-
}
358+
eprintln!("\npython formatting does not match! Printing diff:");
359+
360+
let _ = run_ruff(
361+
root_path,
362+
outdir,
363+
py_path,
364+
&cfg_args,
365+
&file_args,
366+
&["format".as_ref(), "--diff".as_ref()],
367+
);
377368
show_bless_help("py:fmt", "reformat Python code", bless);
378369
}
379370

@@ -425,7 +416,7 @@ fn check_cpp_fmt(
425416
let args = merge_args(&cfg_args_clang_format, &file_args_clang_format);
426417
let res = py_runner(py_path, false, None, "clang-format", &args);
427418

428-
if res.is_err() && !bless && show_diff() {
419+
if res.is_err() && !bless {
429420
eprintln!("\nclang-format linting failed! Printing diff suggestions:");
430421

431422
let mut cfg_args_diff = cfg_args.clone();

0 commit comments

Comments
 (0)