# Hook used to indent all xcos files before commiting
#
-XMLLINT="$(git config hooks.xmllint)"
+XMLLINT="$(git config --get hooks.xmllint)"
if test ! -x "$XMLLINT"
then
echo "Unable to find xmllint executable on the configuration."
echo
fi
-INDENT="$(git config hooks.indent)"
+if test -z "$(git config --get-all xmllint.ignored)"
+then
+ echo "Unable to find xmllint ignored list on the configuration, ignored"
+ echo
+ echo "You can configure it with :"
+ echo " git config --add xmllint.ignored 'scilab/Visual-Studio-settings/*.xml' "
+ echo " git config --add xmllint.ignored 'scilab/checkstyle/*.xml' "
+ echo
+
+ XMLLINT_IGNORED=""
+else
+ XMLLINT_IGNORED="$(find $(git config --get-all xmllint.ignored))"
+fi
+
+INDENT="$(git config --get hooks.indent)"
if test ! -x "$INDENT"
then
echo "Unable to find indent executable on the configuration."
echo
fi
+if test -z "$(git config --get-all indent.ignored)"
+then
+ echo "Unable to find indent ignored list on the configuration, ignored"
+ echo
+ echo "You can configure it with :"
+ echo " git config --add indent.ignored 'scilab/modules/*/src/jni/*.hxx' "
+ echo " git config --add indent.ignored 'scilab/modules/*/src/jni/*.cpp' "
+ echo
+
+ INDENT_IGNORED=""
+else
+ INDENT_IGNORED="$(find $(git config --get-all indent.ignored))"
+fi
+
# indent / format file by type
indent() {
# getting against as the current commit
return;
fi
- echo "Formatting " $file
+ # ignored globs
+ if test -n "$XMLLINT_IGNORED"
+ then
+ echo $XMLLINT_IGNORED |grep -q $file
+ if test $? -eq 0
+ then
+ echo "Formatting" $file ": ignored"
+ return
+ fi
+ fi
+
+ echo "Formatting" $file
"$XMLLINT" --format -o "$file" "$file"
git add "$file"
}
return;
fi
- echo "Indenting " $file
+ # ignored globs
+ if test -n "$INDENT_IGNORED"
+ then
+ echo $INDENT_IGNORED |grep -q "$file"
+ if test $? -eq 0
+ then
+ echo "Indenting" $file ": ignored"
+ return
+ fi
+ fi
+
+
+ echo "Indenting" $file
"$INDENT" -npro --braces-after-if-line -i4 -ts4 -sob -ss -ncs -sc --no-space-after-parentheses -cp1 --no-tabs -bap -bad -npcs --dont-break-function-decl-args --dont-break-procedure-type -bli0 -l150 -il0 "$file"
git add "$file"
}
indent
+