matrixion/.ci/format.sh

35 lines
866 B
Bash
Raw Normal View History

#!/usr/bin/env sh
2017-09-24 17:08:11 +03:00
# Runs the Clang Formatter
# Return codes:
# - 1 there are files to be formatted
# - 0 everything looks fine
set -eu
2017-09-24 17:08:11 +03:00
2021-03-05 02:35:15 +03:00
FILES=$(find src -type f \( -iname "*.cpp" -o -iname "*.h" \))
2023-10-26 22:03:36 +03:00
QML_FILES=$(find resources/qml -type f \( -iname "*.qml" \))
2017-09-24 17:08:11 +03:00
for f in $FILES
do
2019-09-08 18:28:26 +03:00
clang-format -i "$f"
done;
2019-09-08 18:28:26 +03:00
2023-10-31 05:11:03 +03:00
if command -v /usr/lib64/qt6/bin/qmlformat &> /dev/null; then
/usr/lib64/qt6/bin/qmlformat -i $QML_FILES
elif command -v /usr/lib/qt6/bin/qmlformat &> /dev/null; then
/usr/lib/qt6/bin/qmlformat -i $QML_FILES
else
echo "No qmlformat found, skipping check!"
fi
2019-09-08 18:28:26 +03:00
git diff --exit-code
2023-10-26 22:03:36 +03:00
if command -v /usr/lib64/qt6/bin/qmllint &> /dev/null; then
/usr/lib64/qt6/bin/qmllint $QML_FILES
elif command -v /usr/lib/qt6/bin/qmllint &> /dev/null; then
/usr/lib/qt6/bin/qmllint $QML_FILES
else
echo "No qmllint found, skipping check!"
fi