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