|
10 | 10 | //! configuration after a double dash (`--extra-checks=py -- foo.py`) |
11 | 11 | //! 2. Build configuration based on args/environment: |
12 | 12 | //! - Formatters by default are in check only mode |
13 | | -//! - If in CI (TIDY_PRINT_DIFF=1 is set), check and print the diff |
14 | 13 | //! - If `--bless` is provided, formatters may run |
15 | 14 | //! - Pass any additional config after the `--`. If no files are specified, |
16 | 15 | //! 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. |
19 | 18 |
|
20 | 19 | use std::ffi::{OsStr, OsString}; |
21 | 20 | use std::path::{Path, PathBuf}; |
@@ -206,12 +205,6 @@ fn show_bless_help(mode: &str, action: &str, bless: bool) { |
206 | 205 | } |
207 | 206 | } |
208 | 207 |
|
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 | | - |
215 | 208 | fn check_spellcheck(root_path: &Path, outdir: &Path, cargo: &Path, tidy_ctx: &TidyCtx) { |
216 | 209 | let mut check = tidy_ctx.start_check("extra_checks:spellcheck"); |
217 | 210 |
|
@@ -318,7 +311,7 @@ fn check_python_lint( |
318 | 311 |
|
319 | 312 | let res = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, args); |
320 | 313 |
|
321 | | - if res.is_err() && !bless && show_diff() { |
| 314 | + if res.is_err() && !bless { |
322 | 315 | eprintln!("\npython linting failed! Printing diff suggestions:"); |
323 | 316 |
|
324 | 317 | let diff_res = run_ruff( |
@@ -362,18 +355,16 @@ fn check_python_fmt( |
362 | 355 | let res = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, &args); |
363 | 356 |
|
364 | 357 | 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 | + ); |
377 | 368 | show_bless_help("py:fmt", "reformat Python code", bless); |
378 | 369 | } |
379 | 370 |
|
@@ -425,7 +416,7 @@ fn check_cpp_fmt( |
425 | 416 | let args = merge_args(&cfg_args_clang_format, &file_args_clang_format); |
426 | 417 | let res = py_runner(py_path, false, None, "clang-format", &args); |
427 | 418 |
|
428 | | - if res.is_err() && !bless && show_diff() { |
| 419 | + if res.is_err() && !bless { |
429 | 420 | eprintln!("\nclang-format linting failed! Printing diff suggestions:"); |
430 | 421 |
|
431 | 422 | let mut cfg_args_diff = cfg_args.clone(); |
|
0 commit comments