Skip to content
Snippets Groups Projects
Commit 21b27b5b authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

Check if .pre-commit hook executables exist (#28)

parent 917e457f
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
# set path to uncrustify binary
# UNCRUSTIFY="/usr/bin/uncrustify"
UNCRUSTIFY="uncrustify"
CLANGFORMAT="clang-format"
 
# set uncrustify config location
# CONFIG="/home/user/.config/uncrustify.cfg"
......@@ -40,6 +41,15 @@ PARSE_EXTS=true
# FILE_EXTS=".c .h .cpp .hpp"
FILE_EXTS=".c .h .cpp .hpp .cxx"
 
##################################################################
# check if uncrustify and clang-format exist in PATH
exec_in_path() {
type $1 >/dev/null 2>&1 || { echo >&2 "Require '$1' executable but it was not found in PATH. Aborting."; exit 1; }
}
exec_in_path "$UNCRUSTIFY"
exec_in_path "$CLANGFORMAT"
##################################################################
# There should be no need to change anything below this line.
 
......@@ -92,7 +102,7 @@ do
# +++ - timestamp
# to both lines working on the same file and having a a/ and b/ prefix.
# Else it can not be applied with 'git apply'.
clang-format "$file" | \
"$CLANGFORMAT" "$file" | \
"$UNCRUSTIFY" -c "$CONFIG" -l "$SOURCE_LANGUAGE" | \
diff -u -- "$file" - | \
sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment