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