2017-11-14 14:53:16 +04:00
|
|
|
#!/bin/bash
|
2017-11-13 19:34:00 +04:00
|
|
|
|
|
|
|
tmp_dir="$(mktemp -d -t tezos_build.XXXXXXXXXX)"
|
|
|
|
failed=no
|
2017-11-27 09:13:12 +04:00
|
|
|
if [ "$1" = "fix" ]; then
|
|
|
|
fix=yes
|
|
|
|
shift 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
files="$@"
|
|
|
|
if [ -z "$files" ]; then
|
|
|
|
files=` find \( -name _build -or \
|
|
|
|
-name .git -or \
|
|
|
|
-wholename ./src/environment/v1.ml -or \
|
|
|
|
-name registerer.ml \) -prune -or \
|
|
|
|
\( -name \*.ml -or -name \*.mli \) -print`
|
|
|
|
fi
|
2017-11-13 19:34:00 +04:00
|
|
|
|
2017-11-27 09:13:12 +04:00
|
|
|
for f in $files ; do
|
2017-11-13 19:34:00 +04:00
|
|
|
ff=$(basename $f)
|
|
|
|
ocp-indent $f > $tmp_dir/$ff
|
2017-11-14 07:57:06 +04:00
|
|
|
diff -U 3 $f $tmp_dir/$ff
|
2017-11-13 19:34:00 +04:00
|
|
|
if [ $? -ne 0 ]; then
|
2018-01-25 17:51:31 +04:00
|
|
|
if [ "$fix" = "yes" ]; then
|
2017-11-14 14:53:16 +04:00
|
|
|
echo "Fix indentation $f"
|
|
|
|
cp $tmp_dir/$ff $f
|
|
|
|
else
|
2017-11-13 19:34:00 +04:00
|
|
|
failed=yes
|
2017-11-14 14:53:16 +04:00
|
|
|
fi
|
2017-11-13 19:34:00 +04:00
|
|
|
fi
|
|
|
|
rm -f $tmp_dir/$ff $tmp_dir/$ff.diff
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $failed = "yes" ]; then
|
|
|
|
exit 2
|
|
|
|
fi
|