fix closure of last <File> in result xml file and add contribution message
[scilab.git] / git_hooks / pre-commit
index 5ba588f..5aaab76 100755 (executable)
@@ -19,7 +19,10 @@ fi
 #
 # Configuration check
 #
-XMLINDENT="$(git config --get hooks.xmlindent)"
+if test ! -x "$XMLINDENT"
+then
+    XMLINDENT="$(git config --get hooks.xmlindent)"
+fi
 if test ! -x "$XMLINDENT"
 then
     echo "Unable to find xmlindent executable on the configuration."
@@ -45,7 +48,10 @@ else
     XMLINDENT_IGNORED="$(find $(git config --get-all xmlindent.ignored))"
 fi
 
-ASTYLE="$(git config --get hooks.astyle)"
+if test ! -x "$ASTYLE"
+then
+    ASTYLE="$(git config --get hooks.astyle)"
+fi
 if test ! -x "$ASTYLE"
 then
     echo "Unable to find astyle executable on the configuration."
@@ -76,6 +82,10 @@ then
     echo "  git config --add astyle.ignored 'scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/IndentScanner.java' "
     echo "  git config --add astyle.ignored 'scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/MatchingBlockScanner.java' "
     echo "  git config --add astyle.ignored 'scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/ScilabLexer.java' "
+    echo "  git config --add astyle.ignored 'scilab/modules/xcos/src/java/org/scilab/modules/xcos/Controller.java' "
+    echo "  git config --add astyle.ignored 'scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaController.java' "
+    echo "  git config --add astyle.ignored 'scilab/modules/xcos/src/java/org/scilab/modules/xcos/Kind.java' "
+    echo "  git config --add astyle.ignored 'scilab/modules/xcos/src/java/org/scilab/modules/xcos/ObjectProperties.java' "
     echo "  git config --add astyle.ignored 'scilab/modules/scicos/src/scicos_sundials/*' "
 
     echo
@@ -100,16 +110,16 @@ indent() {
     # get the modified files per kind filtering out ignored files and call the
     # __indent_XXX helper
 
-    FILES=$(git diff --cached --name-only $against |grep -E "\.(xcos|xml|xsl)$" |grep -v -F "$XMLINDENT_IGNORED")
+    FILES=$(git diff --cached --name-only --diff-filter=ACM $against |grep -E "\.(xcos|xml|xsl)$" |grep -v -F "$XMLINDENT_IGNORED")
     [ -z "$FILES" ] || __indent_xml;
 
-    FILES=$(git diff --cached --name-only $against |grep -E "\.(h|c|hxx|cpp)$" |grep -v -F "$ASTYLE_IGNORED")
+    FILES=$(git diff --cached --name-only --diff-filter=ACM $against |grep -E "\.(h|c|hxx|cpp)$" |grep -v -F "$ASTYLE_IGNORED")
     [ -z "$FILES" ] || __indent_C;
 
-    FILES=$(git diff --cached --name-only $against |grep -E "\.java$" |grep -v -F "$ASTYLE_IGNORED")
+    FILES=$(git diff --cached --name-only --diff-filter=ACM $against |grep -E "\.java$" |grep -v -F "$ASTYLE_IGNORED")
     [ -z "$FILES" ] || __indent_java;
 
-    FILES=$(git diff --cached --name-only $against |grep -E "\.(sce|sci|tst)$")
+    FILES=$(git diff --cached --name-only --diff-filter=ACM $against |grep -E "\.(sce|sci|tst)$")
     [ -z "$FILES" ] || __indent_scilab;
 
     return 0;
@@ -177,7 +187,7 @@ __indent_scilab() {
         scilab/bin/scilab -nw -f $TMPFILE || return 2
     else
         if test -f scilab/bin/WScilex.exe; then
-            scilab/bin/scilex.exe -f $TMPFILE || return 2
+            scilab/bin/wscilex.exe -nw -f $TMPFILE || return 2
         else
             echo "Scilab has not been built."
             rm $TMPFILE