]>
Commit | Line | Data |
---|---|---|
078a94e0 VZ |
1 | #!/bin/sh |
2 | ||
3 | REPOS="$1" | |
4 | TXN="$2" | |
5 | ||
6 | SVNLOOK=/usr/bin/svnlook | |
7 | ||
0126e6d2 VZ |
8 | svnl() { |
9 | cmd=$1 | |
10 | shift | |
11 | $SVNLOOK $cmd "$REPOS" -t "$TXN" $* | |
3347f618 VZ |
12 | } |
13 | ||
0126e6d2 VZ |
14 | rc=0 |
15 | ||
16 | # exclude all third-party files from consideration, we don't want to do any | |
17 | # checks for them | |
eeea7e8c VZ |
18 | # |
19 | # Also don't impose any constraints on commits to previous 2.x branches. | |
0126e6d2 | 20 | all_changed_files=`svnl changed | \ |
078a94e0 | 21 | grep "^[AU]" | \ |
0126e6d2 | 22 | sed 's/^....//' | \ |
eeea7e8c | 23 | egrep -v "branches/WX_2_" | \ |
f14e42ce | 24 | egrep -v "src/(tiff|regex|jpeg|stc/scintilla)" | \ |
5caded22 RD |
25 | egrep -v "_wrap.cpp" | \ |
26 | egrep -v "wxPython/.*/docs/.*\.html$"` | |
078a94e0 | 27 | |
0126e6d2 VZ |
28 | # analyze the changed files to find all non-binary and all source files |
29 | for f in $all_changed_files; do | |
30 | mimetype=`svnl proplist -v $f | | |
31 | fgrep "svn:mime-type" | | |
32 | sed 's/^ svn:mime-type : //'` | |
33 | case $mimetype in | |
34 | ''|text/*) | |
35 | ;; | |
36 | ||
37 | *) | |
38 | continue | |
39 | ;; | |
40 | esac | |
41 | ||
42 | changed_text_files="$changed_text_files $f" | |
43 | ||
44 | case $f in | |
45 | *.cpp|*.h|*.py) | |
46 | changed_sources="$changed_sources $f" | |
47 | ;; | |
48 | esac | |
49 | done | |
3347f618 VZ |
50 | |
51 | for f in $changed_sources; do | |
0126e6d2 | 52 | if svnl cat $f | fgrep -q ' '; then |
078a94e0 VZ |
53 | echo "Please remove TABs from $f before committing." >&2 |
54 | rc=1 | |
55 | fi | |
f1cfa113 VZ |
56 | |
57 | case $f in | |
58 | */wx/chartype.h) | |
59 | # This file defines _T() for compatibility so don't check it. | |
60 | ;; | |
61 | ||
62 | *) | |
63 | if svnl cat $f | fgrep -qw '_T'; then | |
64 | echo "Please use wxT() instead of _T() in $f." >&2 | |
65 | rc=1 | |
66 | fi | |
67 | ;; | |
68 | esac | |
078a94e0 VZ |
69 | done |
70 | ||
0126e6d2 VZ |
71 | for f in $changed_text_files; do |
72 | if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then | |
3347f618 | 73 | echo "File $f doesn't use UTF-8, please convert it before committing." >&2 |
0126e6d2 | 74 | echo "(or set svn:mime-type property correctly if the file is binary)." >&2 |
3347f618 VZ |
75 | rc=1 |
76 | fi | |
77 | done | |
78 | ||
078a94e0 | 79 | exit $rc |
f14e42ce | 80 |