Add a git hook to launch the indentation on Scilab code 67/10667/4
Sylvestre Ledru [Sun, 3 Mar 2013 10:30:23 +0000 (11:30 +0100)]
Change-Id: I22666ef89fcf68bafd20c01783b898a036cd92cb

git_hooks/pre-commit

index e1af790..01b22a4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 #
-# Hook used to indent all xcos files before commiting
+# Hook used to indent files before commiting
 #
 
 
@@ -111,6 +111,9 @@ indent() {
         .java)
             __indent_java;
         ;;
+        .sce|.sci)
+            __indent_scilab;
+        ;;
         esac
     done
 
@@ -194,5 +197,23 @@ __indent_java() {
     return 0
 }
 
+# Indent the file with `scinotes' if this is a Scilab file
+__indent_scilab() {
+    __pre_indent || return 1
+    if test -f scilab/scilab-bin; then
+        scilab/bin/scinotes -indent "$file" || return 2
+    else
+        if test -f scilab/bin/WScilex.exe; then
+            scilab/bin/scilex.exe -e "scinotes('$file', ['indent','trailing','quote'])" || return 2
+        else
+            echo "Scilab has not been built."
+            return 4
+        fi
+    fi
+
+    __post_indent || return 3
+    return 0
+}
+
 indent