From 59b43986e9dabde9d4cec7b3b65626adfcedd4a2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 24 Jul 2025 08:48:48 +0200 Subject: [PATCH] build_tools/style.fish: fail if formatters are not available build_tools/check.sh is supposed to fail on formatting violations. I don't think we have a good reason for running build_tools/style.fish outside check.sh. black is the only formatter not versioned in CI -- but we can probably satisfy all realistic versions. Ref: https://github.com/fish-shell/fish-shell/pull/11608#discussion_r2173176621 --- build_tools/style.fish | 79 ++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/build_tools/style.fish b/build_tools/style.fish index f47a831a9..28a023919 100755 --- a/build_tools/style.fish +++ b/build_tools/style.fish @@ -62,17 +62,16 @@ if set -q fish_files[1] if not type -q fish_indent echo echo $yellow'Could not find `fish_indent` in `$PATH`.'$normal - echo - else - echo === Running "$green"fish_indent"$normal" - if set -l -q _flag_check - if not fish_indent --check -- $fish_files - echo $red"Fish files are not formatted correctly."$normal - exit 1 - end - else - fish_indent -w -- $fish_files + exit 127 + end + echo === Running "$green"fish_indent"$normal" + if set -l -q _flag_check + if not fish_indent --check -- $fish_files + echo $red"Fish files are not formatted correctly."$normal + exit 1 end + else + fish_indent -w -- $fish_files end end @@ -80,17 +79,16 @@ if set -q python_files[1] if not type -q black echo echo $yellow'Please install `black` to style python'$normal - echo - else - echo === Running "$green"black"$normal" - if set -l -q _flag_check - if not black --check $python_files - echo $red"Python files are not formatted correctly."$normal - exit 1 - end - else - black $python_files + exit 127 + end + echo === Running "$green"black"$normal" + if set -l -q _flag_check + if not black --check $python_files + echo $red"Python files are not formatted correctly."$normal + exit 1 end + else + black $python_files end end @@ -98,30 +96,29 @@ if not cargo fmt --version >/dev/null echo echo $yellow'Please install "rustfmt" to style Rust, e.g. via:' echo "rustup component add rustfmt"$normal - echo -else - echo === Running "$green"rustfmt"$normal" - if set -l -q _flag_check - if set -l -q _flag_all - if not cargo fmt --check - echo $red"Rust files are not formatted correctly."$normal - exit 1 - end - else - if set -q rust_files[1] - if not rustfmt --check --files-with-diff $rust_files - echo $red"Rust files are not formatted correctly." - exit 1 - end - end + exit 127 +end +echo === Running "$green"rustfmt"$normal" +if set -l -q _flag_check + if set -l -q _flag_all + if not cargo fmt --check + echo $red"Rust files are not formatted correctly."$normal + exit 1 end else - if set -l -q _flag_all - cargo fmt - else - if set -q rust_files[1] - rustfmt $rust_files + if set -q rust_files[1] + if not rustfmt --check --files-with-diff $rust_files + echo $red"Rust files are not formatted correctly." + exit 1 end end end +else + if set -l -q _flag_all + cargo fmt + else + if set -q rust_files[1] + rustfmt $rust_files + end + end end