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