Commit 2a79b9f6 authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: Improve Uncrustify pre-commit hook

Make sure that we don't run into an error when uncrustify
is disabled, by providing info on how to set it up.

Also allow to skip uncrustify (not recommended).
parent 9f7d8c92
......@@ -47,6 +47,12 @@ fi
##################################################################
# CONFIGURATION
# set if uncrustify is enabled or not
ENABLED=$(git config --get uncrustify.enabled)
# set if uncrustify can ne skipped
SKIP=$(git config --get uncrustify.skip)
# set uncrustify path or executable
# UNCRUSTIFY="/usr/bin/uncrustify"
UNCRUSTIFY=$(git config --get uncrustify.path)
......@@ -82,6 +88,25 @@ FILE_EXTS=".c .h .cpp .hpp"
# exit on error
set -e
# if uncrustify disabled, quit
if [[ ! "$ENABLED" == "true" ]]; then
printf "Uncrustify is disabled in Git config, can not run style checking.\n"
printf "\nTo enable Uncrustify, do:\n"
printf "\tgit config uncrustify.enabled true\n"
printf "\tgit config uncrustify.path path/to/uncrustify #should be in Superbuild/Uncrustify-build/bin\n"
printf "\tgit config uncrustify.conf path/to/config.cfg #should be in Utilities/Uncrustify\n"
if [[ "$SKIP" == "true" ]]; then
printf "\nTo stop skipping style checking (recommended), do:\n"
printf "\tgit config uncrustify.skip false\n\n"
exit 0;
else
printf "\nTo skip style checking (not recommended), do:\n"
printf "\tgit config uncrustify.skip true\n\n"
exit 1;
fi
fi
# check whether the given file matches any of the set extensions
matches_extension() {
local filename="$(basename -- "$1")"
......@@ -192,4 +217,4 @@ printf "(may need to be called from the root directory of your repository)\n"
printf "Aborting commit. Apply changes and commit again or skip checking with"
printf " --no-verify (not recommended).\n"
exit 1
\ No newline at end of file
exit 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment