summaryrefslogtreecommitdiffstats
path: root/git_hooks
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab-enterprises.com>2013-03-03 11:30:23 +0100
committercodereview <codereview@git.scilab.org>2013-03-13 11:48:41 +0100
commit9eb7d133745df193fe52d758e4c376810c99c399 (patch)
treecd537f36f53fcab8a0006eba05005e69b951d66e /git_hooks
parent05402331bde341ee26c453bc4d722f3af23c305b (diff)
downloadscilab-9eb7d133745df193fe52d758e4c376810c99c399.zip
scilab-9eb7d133745df193fe52d758e4c376810c99c399.tar.gz
Add a git hook to launch the indentation on Scilab code
Change-Id: I22666ef89fcf68bafd20c01783b898a036cd92cb
Diffstat (limited to 'git_hooks')
-rwxr-xr-xgit_hooks/pre-commit23
1 files changed, 22 insertions, 1 deletions
diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit
index e1af790..01b22a4 100755
--- a/git_hooks/pre-commit
+++ b/git_hooks/pre-commit
@@ -1,6 +1,6 @@
1#!/usr/bin/env sh 1#!/usr/bin/env sh
2# 2#
3# Hook used to indent all xcos files before commiting 3# Hook used to indent files before commiting
4# 4#
5 5
6 6
@@ -111,6 +111,9 @@ indent() {
111 .java) 111 .java)
112 __indent_java; 112 __indent_java;
113 ;; 113 ;;
114 .sce|.sci)
115 __indent_scilab;
116 ;;
114 esac 117 esac
115 done 118 done
116 119
@@ -194,5 +197,23 @@ __indent_java() {
194 return 0 197 return 0
195} 198}
196 199
200# Indent the file with `scinotes' if this is a Scilab file
201__indent_scilab() {
202 __pre_indent || return 1
203 if test -f scilab/scilab-bin; then
204 scilab/bin/scinotes -indent "$file" || return 2
205 else
206 if test -f scilab/bin/WScilex.exe; then
207 scilab/bin/scilex.exe -e "scinotes('$file', ['indent','trailing','quote'])" || return 2
208 else
209 echo "Scilab has not been built."
210 return 4
211 fi
212 fi
213
214 __post_indent || return 3
215 return 0
216}
217
197indent 218indent
198 219