forked from xamarin/mobile-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pre-commit.posix
37 lines (31 loc) · 920 Bytes
/
pre-commit.posix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
run_validator()
{
mono --debug xcsv.exe $1 $2 $3;
if [ $? != 0 ]; then
exit 1;
fi;
}
for dir in `find . -maxdepth 1 -type d | grep -v "\.$" | grep -v "\./\." | sed "s/^\.\///"`; do
build_done="false"
for file in `git diff --cached --name-only | grep "^$dir\/"`; do
if ! [ -d $dir ]; then
break;
fi;
if [ -f $dir/Makefile ]; then
break;
fi;
if [ $file == $dir/README.md ]; then
run_validator markdown $dir;
elif [ $file == $dir/Metadata.xml ]; then
run_validator metadata $dir;
elif [ `echo $file | grep "^$dir\/Screenshots\/"` ]; then
run_validator screenshot $dir;
else
if [ $build_done == "false" ]; then
run_validator build $dir mdtool-build;
build_done="true"
fi;
fi;
done;
done;