diff options
author | Sylvestre Ledru <sylvestre.ledru@scilab-enterprises.com> | 2012-01-12 19:09:27 +0100 |
---|---|---|
committer | Vincent COUVERT <vincent.couvert@scilab.org> | 2012-01-13 10:31:36 +0100 |
commit | 01bf006f11ef8ed97b255593b1175a76b464a6c0 (patch) | |
tree | 6c7d34b62f011edb228ee6ad045a93712a6353a8 /git_hooks/pre-commit | |
parent | c35b803951d92b9b2ee87a9445ed835872a18939 (diff) | |
download | scilab-01bf006f11ef8ed97b255593b1175a76b464a6c0.zip scilab-01bf006f11ef8ed97b255593b1175a76b464a6c0.tar.gz |
Use xmlindent of xmllint to provide better formated xml files
Change-Id: I228a806bc1958a5a6739fdc0560c8d315a6437ab
Diffstat (limited to 'git_hooks/pre-commit')
-rwxr-xr-x | git_hooks/pre-commit | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit index 78fca1d..73bac24 100755 --- a/git_hooks/pre-commit +++ b/git_hooks/pre-commit | |||
@@ -19,31 +19,31 @@ fi | |||
19 | # | 19 | # |
20 | # Configuration check | 20 | # Configuration check |
21 | # | 21 | # |
22 | XMLLINT="$(git config --get hooks.xmllint)" | 22 | XMLINDENT="$(git config --get hooks.xmlindent)" |
23 | 23 | ||
24 | if test ! -x "$XMLLINT" | 24 | if test ! -x "$XMLINDENT" |
25 | then | 25 | then |
26 | echo "Unable to find xmllint executable on the configuration." | 26 | echo "Unable to find xmlindent executable on the configuration." |
27 | echo | 27 | echo |
28 | echo "Please configure it with :" | 28 | echo "Please configure it with :" |
29 | echo " git config --global hooks.xmllint C:/path/to/xmllint" | 29 | echo " git config --global hooks.xmlindent C:/path/to/xmlindent" |
30 | echo " or " | 30 | echo " or " |
31 | echo " git config --global hooks.xmllint /usr/bin/xmllint" | 31 | echo " git config --global hooks.xmlindent /usr/bin/xmlindent" |
32 | echo | 32 | echo |
33 | fi | 33 | fi |
34 | 34 | ||
35 | if test -z "$(git config --get-all xmllint.ignored)" | 35 | if test -z "$(git config --get-all xmlindent.ignored)" |
36 | then | 36 | then |
37 | echo "Unable to find xmllint ignored list on the configuration, ignored" | 37 | echo "Unable to find xmlindent ignored list on the configuration, ignored" |
38 | echo | 38 | echo |
39 | echo "You can configure it with :" | 39 | echo "You can configure it with :" |
40 | echo " git config --add xmllint.ignored 'scilab/Visual-Studio-settings/*.xml' " | 40 | echo " git config --add xmlindent.ignored 'scilab/Visual-Studio-settings/*.xml' " |
41 | echo " git config --add xmllint.ignored 'scilab/checkstyle/*.xml' " | 41 | echo " git config --add xmlindent.ignored 'scilab/checkstyle/*.xml' " |
42 | echo | 42 | echo |
43 | 43 | ||
44 | XMLLINT_IGNORED="" | 44 | XMLINDENT_IGNORED="" |
45 | else | 45 | else |
46 | XMLLINT_IGNORED="$(find $(git config --get-all xmllint.ignored))" | 46 | XMLINDENT_IGNORED="$(find $(git config --get-all xmlindent.ignored))" |
47 | fi | 47 | fi |
48 | 48 | ||
49 | INDENT="$(git config --get hooks.indent)" | 49 | INDENT="$(git config --get hooks.indent)" |
@@ -99,10 +99,10 @@ indent() { | |||
99 | esac | 99 | esac |
100 | done | 100 | done |
101 | } | 101 | } |
102 | # Indent the file with xmllint if this is an xcos file | 102 | # Indent the file with xmlindent if this is an xcos file |
103 | __indent_Xml() { | 103 | __indent_Xml() { |
104 | 104 | ||
105 | if test ! -x "$XMLLINT" | 105 | if test ! -x "$XMLINDENT" |
106 | then | 106 | then |
107 | return; | 107 | return; |
108 | fi | 108 | fi |
@@ -112,9 +112,9 @@ __indent_Xml() { | |||
112 | fi | 112 | fi |
113 | 113 | ||
114 | # ignored globs | 114 | # ignored globs |
115 | if test -n "$XMLLINT_IGNORED" | 115 | if test -n "$XMLINDENT_IGNORED" |
116 | then | 116 | then |
117 | echo $XMLLINT_IGNORED |grep -q $file | 117 | echo $XMLINDENT_IGNORED |grep -q $file |
118 | if test $? -eq 0 | 118 | if test $? -eq 0 |
119 | then | 119 | then |
120 | echo "Formatting" $file ": ignored" | 120 | echo "Formatting" $file ": ignored" |
@@ -123,7 +123,7 @@ __indent_Xml() { | |||
123 | fi | 123 | fi |
124 | 124 | ||
125 | echo "Formatting" $file | 125 | echo "Formatting" $file |
126 | "$XMLLINT" --format -o "$file" "$file" | 126 | "$XMLINDENT" -i 2 -o "$file" "$file" |
127 | git add "$file" | 127 | git add "$file" |
128 | } | 128 | } |
129 | # Indent the file with `indent' if this is a C/CPP file | 129 | # Indent the file with `indent' if this is a C/CPP file |