]> git.saurik.com Git - wxWidgets.git/blob - misc/scripts/svn/hooks/pre-commit
Don't exclude message catalog files from UTF-8 checks in svn hook.
[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 egrep -v "wxPython/.*/docs/.*\.html$"`
24
25 # analyze the changed files to find all non-binary and all source files
26 for f in $all_changed_files; do
27 mimetype=`svnl proplist -v $f |
28 fgrep "svn:mime-type" |
29 sed 's/^ svn:mime-type : //'`
30 case $mimetype in
31 ''|text/*)
32 ;;
33
34 *)
35 continue
36 ;;
37 esac
38
39 changed_text_files="$changed_text_files $f"
40
41 case $f in
42 *.cpp|*.h|*.py)
43 changed_sources="$changed_sources $f"
44 ;;
45 esac
46 done
47
48 for f in $changed_sources; do
49 if svnl cat $f | fgrep -q ' '; then
50 echo "Please remove TABs from $f before committing." >&2
51 rc=1
52 fi
53
54 case $f in
55 */wx/chartype.h)
56 # This file defines _T() for compatibility so don't check it.
57 ;;
58
59 *)
60 if svnl cat $f | fgrep -qw '_T'; then
61 echo "Please use wxT() instead of _T() in $f." >&2
62 rc=1
63 fi
64 ;;
65 esac
66 done
67
68 for f in $changed_text_files; do
69 if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then
70 echo "File $f doesn't use UTF-8, please convert it before committing." >&2
71 echo "(or set svn:mime-type property correctly if the file is binary)." >&2
72 rc=1
73 fi
74 done
75
76 exit $rc
77