mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-05 20:39:59 -08:00
* update format.sh add shellcheck to format.sh add statement macros to .clang-format add no clang format to format.sh add changed file list to format.sh diff rename --cf-version to --print-version in format.sh lint files * enable --shell on ci runs * remove useless semicolons removes the semicolons after empty function definitions these semicolons are optional, they don't do anything this will have functions be consistently formatted if we want to keep the option to have these on the same line like they were before we should use the option AllowShortFunctionsOnASingleLine: None * fix script * update echo line in lint_cpp.sh which doesn't lint cpp only at all
80 lines
2.0 KiB
Bash
Executable File
80 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# fetch master branch
|
|
git fetch origin master
|
|
|
|
# unshallow if needed
|
|
echo "Finding merge base"
|
|
if ! git merge-base origin/master HEAD; then
|
|
echo "Could not find merge base, unshallowing repo"
|
|
git fetch --unshallow
|
|
fi
|
|
|
|
# Check formatting using format.sh
|
|
echo "Checking your code using format.sh..."
|
|
|
|
diff="$(./format.sh --diff --cmake --shell --print-version --branch origin/master)"
|
|
err=$?
|
|
|
|
sep="
|
|
----------
|
|
"
|
|
used_version="${diff%%"$sep"*}"
|
|
diff="${diff#*"$sep"}"
|
|
changes_to_make="${diff%%"$sep"*}"
|
|
files_to_edit="${diff#*"$sep"}"
|
|
|
|
case $err in
|
|
1)
|
|
cat <<EOM
|
|
|
|
***********************************************************
|
|
*** ***
|
|
*** Your code does not comply with our style guide. ***
|
|
*** ***
|
|
*** Please correct it or run the "format.sh" script. ***
|
|
*** Then commit and push those changes to this branch. ***
|
|
*** Check our CONTRIBUTING.md file for more details. ***
|
|
*** ***
|
|
*** Thank you ❤️ ***
|
|
*** ***
|
|
***********************************************************
|
|
|
|
Used version:
|
|
$used_version
|
|
|
|
Affected files:
|
|
$files_to_edit
|
|
|
|
The following changes should be made:
|
|
$changes_to_make
|
|
|
|
Exiting...
|
|
EOM
|
|
exit 2
|
|
;;
|
|
|
|
0)
|
|
cat <<EOM
|
|
|
|
***********************************************************
|
|
*** ***
|
|
*** Your code complies with our style guide! ***
|
|
*** ***
|
|
*** Awesome 👍 ***
|
|
*** ***
|
|
***********************************************************
|
|
|
|
Used version:
|
|
$used_version
|
|
|
|
Exiting...
|
|
EOM
|
|
exit 0
|
|
;;
|
|
|
|
*)
|
|
echo "Something went wrong in our formatting checks: format.sh returned $err" >&2
|
|
;;
|
|
esac
|