]> git.saurik.com Git - wxWidgets.git/blob - misc/scripts/svn/hooks/pre-commit
exclude SWIG generated files from being checked
[wxWidgets.git] / misc / scripts / svn / hooks / pre-commit
1 #!/bin/sh
2
3 REPOS="$1"
4 TXN="$2"
5
6 SVNLOOK=/usr/bin/svnlook
7
8 svnl() {
9 cmd=$1
10 shift
11 $SVNLOOK $cmd "$REPOS" -t "$TXN" $*
12 }
13
14 rc=0
15
16 # exclude all third-party files from consideration, we don't want to do any
17 # checks for them
18 all_changed_files=`svnl changed | \
19 grep "^[AU]" | \
20 sed 's/^....//' | \
21 egrep -v "src/(tiff|regex|jpeg|stc/scintilla)" | \
22 egrep -v "_wrap.cpp"`
23
24 # analyze the changed files to find all non-binary and all source files
25 for f in $all_changed_files; do
26 mimetype=`svnl proplist -v $f |
27 fgrep "svn:mime-type" |
28 sed 's/^ svn:mime-type : //'`
29 case $mimetype in
30 ''|text/*)
31 ;;
32
33 *)
34 continue
35 ;;
36 esac
37
38 changed_text_files="$changed_text_files $f"
39
40 case $f in
41 *.cpp|*.h|*.py)
42 changed_sources="$changed_sources $f"
43 ;;
44 esac
45 done
46
47 for f in $changed_sources; do
48 if svnl cat $f | fgrep -q ' '; then
49 echo "Please remove TABs from $f before committing." >&2
50 rc=1
51 fi
52 done
53
54 for f in $changed_text_files; do
55 if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then
56 echo "File $f doesn't use UTF-8, please convert it before committing." >&2
57 echo "(or set svn:mime-type property correctly if the file is binary)." >&2
58 rc=1
59 fi
60 done
61
62 exit $rc
63