]>
Commit | Line | Data |
---|---|---|
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 | # | |
19 | # Also don't impose any constraints on commits to previous 2.x branches. | |
20 | all_changed_files=`svnl changed | \ | |
21 | grep "^[AU]" | \ | |
22 | sed 's/^....//' | \ | |
23 | egrep -v "branches/WX_2_" | \ | |
24 | egrep -v "wxWidgets/vendor" | \ | |
25 | egrep -v "src/(tiff|regex|jpeg|stc/scintilla)" | \ | |
26 | egrep -v "_wrap.cpp" | \ | |
27 | egrep -v "wxPython/.*/docs/.*\.html$"` | |
28 | ||
29 | # analyze the changed files to find all non-binary and all source files | |
30 | for f in $all_changed_files; do | |
31 | mimetype=`svnl proplist -v $f | | |
32 | fgrep "svn:mime-type" | | |
33 | sed 's/^ svn:mime-type : //'` | |
34 | case $mimetype in | |
35 | ''|text/*) | |
36 | ;; | |
37 | ||
38 | *) | |
39 | continue | |
40 | ;; | |
41 | esac | |
42 | ||
43 | changed_text_files="$changed_text_files $f" | |
44 | ||
45 | case $f in | |
46 | *.cpp|*.h|*.py) | |
47 | changed_sources="$changed_sources $f" | |
48 | ;; | |
49 | esac | |
50 | done | |
51 | ||
52 | for f in $changed_sources; do | |
53 | if svnl cat $f | fgrep -q ' '; then | |
54 | echo "Please remove TABs from $f before committing." >&2 | |
55 | rc=1 | |
56 | fi | |
57 | ||
58 | case $f in | |
59 | */wx/chartype.h) | |
60 | # This file defines _T() for compatibility so don't check it. | |
61 | ;; | |
62 | ||
63 | */docs/doxygen/overviews/changes_since28.h) | |
64 | # And this one describes changes from _T() to wxT(). | |
65 | ;; | |
66 | ||
67 | *) | |
68 | if svnl cat $f | fgrep -qw '_T'; then | |
69 | echo "Please use wxT() instead of _T() in $f." >&2 | |
70 | rc=1 | |
71 | fi | |
72 | ;; | |
73 | esac | |
74 | done | |
75 | ||
76 | for f in $changed_text_files; do | |
77 | if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then | |
78 | echo "File $f doesn't use UTF-8, please convert it before committing." >&2 | |
79 | echo "(or set svn:mime-type property correctly if the file is binary)." >&2 | |
80 | rc=1 | |
81 | fi | |
82 | done | |
83 | ||
84 | exit $rc | |
85 |