CI: Print colored diff for lint check (#6975)

* print colored diff in gha

* use spaces
This commit is contained in:
tooomm
2026-06-08 19:19:28 +02:00
committed by GitHub
parent 20cdcdb382
commit dc152e89f7
2 changed files with 6 additions and 26 deletions
+2 -22
View File
@@ -13,17 +13,9 @@ fi
# Check formatting using format.sh # Check formatting using format.sh
echo "Checking your code using format.sh..." echo "Checking your code using format.sh..."
diff="$(./format.sh --diff --cmake --shell --print-version --branch origin/master)" ./format.sh --color-diff --cmake --shell --print-version --branch origin/master
err=$? err=$?
sep="
----------
"
used_version="${diff%%"$sep"*}"
diff="${diff#*"$sep"}"
changes_to_make="${diff%%"$sep"*}"
files_to_edit="${diff#*"$sep"}"
case $err in case $err in
1) 1)
cat <<EOM cat <<EOM
@@ -36,19 +28,10 @@ case $err in
*** Then commit and push those changes to this branch. *** *** Then commit and push those changes to this branch. ***
*** Check our CONTRIBUTING.md file for more details. *** *** Check our CONTRIBUTING.md file for more details. ***
*** *** *** ***
*** Thank you ❤️ *** *** Thank you ❤️ ***
*** *** *** ***
*********************************************************** ***********************************************************
Used version:
$used_version
Affected files:
$files_to_edit
The following changes should be made:
$changes_to_make
Exiting... Exiting...
EOM EOM
exit 2 exit 2
@@ -65,9 +48,6 @@ EOM
*** *** *** ***
*********************************************************** ***********************************************************
Used version:
$used_version
Exiting... Exiting...
EOM EOM
exit 0 exit 0
+4 -4
View File
@@ -3,7 +3,7 @@
# This script will run clang-format on all modified, non-3rd-party C++/Header files. # This script will run clang-format on all modified, non-3rd-party C++/Header files.
# Optionally runs cmake-format on all modified cmake files. # Optionally runs cmake-format on all modified cmake files.
# Optionally runs shellcheck on all modified shell files. # Optionally runs shellcheck on all modified shell files.
# Uses clang-format cmake-format git diff find shellcheck # Uses clang-format, cmake-format, git, diff, find and shellcheck
# Never, ever, should this receive a path with a newline in it. Don't bother proofing it for that. # Never, ever, should this receive a path with a newline in it. Don't bother proofing it for that.
set -o pipefail set -o pipefail
@@ -103,11 +103,11 @@ OPTIONS:
Do not check any source files for clang-format. Do not check any source files for clang-format.
--print-version --print-version
Print the version of clang-format being used before continuing. Print the lint tool version being used before continuing.
--shell --shell
Use shellcheck to lint shell files. Not available in the default inline Use shellcheck to lint shell files.
mode. Not available in the default inline mode.
-t, --test -t, --test
Do not edit files in place. Set exit code to 1 if changes are required. Do not edit files in place. Set exit code to 1 if changes are required.