|
|
|
@ -5,9 +5,17 @@
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------ |
|
|
|
|
|
|
|
|
|
# Get the full path to this script while handling spaces and symlinks correctly |
|
|
|
|
scriptPath="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" |
|
|
|
|
cd "$scriptPath/.." || exit 1 |
|
|
|
|
b="$(tput bold)" |
|
|
|
|
red="$(tput setf 4)" |
|
|
|
|
n="$(tput sgr0)" |
|
|
|
|
|
|
|
|
|
if [ ! -d ".git" ]; then |
|
|
|
|
echo "${b}${red}Error:${n} please run this script from the project root" >&2 |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Get the path from the project root to the script |
|
|
|
|
subDir="$(dirname -- "$0")" |
|
|
|
|
|
|
|
|
|
# Get all files staged for commit |
|
|
|
|
files="$(git --no-pager diff --cached --name-only)" |
|
|
|
@ -23,21 +31,21 @@ lint-shell-script.sh
|
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
for linter in $linters; do |
|
|
|
|
echo "Running script/$linter" |
|
|
|
|
if "script/$linter" "$files"; then |
|
|
|
|
echo "[${green}PASS${nc}]: script/$linter" |
|
|
|
|
echo "Running $subDir/$linter" |
|
|
|
|
if "$subDir/$linter" "$files"; then |
|
|
|
|
echo "[${green}PASS${nc}]: $subDir/$linter" |
|
|
|
|
else |
|
|
|
|
echo "[${red}FAIL${nc}]: script/$linter" |
|
|
|
|
echo "[${red}FAIL${nc}]: $subDir/$linter" |
|
|
|
|
failures=$(( failures + 1 )) |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
echo "Running script/lint-clang-format.sh" |
|
|
|
|
echo "Running $subDir/lint-clang-format.sh" |
|
|
|
|
# shellcheck disable=SC2086 |
|
|
|
|
if script/lint-clang-format.sh "$files" && git diff --exit-code $files; then |
|
|
|
|
echo "[${green}PASS${nc}]: script/lint-clang-format.sh" |
|
|
|
|
if "$subDir/lint-clang-format.sh" "$files" && git diff --exit-code $files; then |
|
|
|
|
echo "[${green}PASS${nc}]: $subDir/lint-clang-format.sh" |
|
|
|
|
else |
|
|
|
|
echo "[${red}FAIL${nc}]: script/lint-clang-format.sh" |
|
|
|
|
echo "[${red}FAIL${nc}]: $subDir/lint-clang-format.sh" |
|
|
|
|
failures=$(( failures + 1 )) |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|