]> git.saurik.com Git - wxWidgets.git/blob - misc/scripts/svn/hooks/pre-commit
Don't exit on errors in the pre-commit 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
23 # analyze the changed files to find all non-binary and all source files
24 for f in $all_changed_files; do
25 mimetype=`svnl proplist -v $f |
26 fgrep "svn:mime-type" |
27 sed 's/^ svn:mime-type : //'`
28 case $mimetype in
29 ''|text/*)
30 ;;
31
32 *)
33 continue
34 ;;
35 esac
36
37 changed_text_files="$changed_text_files $f"
38
39 case $f in
40 *.cpp|*.h|*.py)
41 changed_sources="$changed_sources $f"
42 ;;
43 esac
44 done
45
46 for f in $changed_sources; do
47 if svnl cat $f | fgrep -q ' '; then
48 echo "Please remove TABs from $f before committing." >&2
49 rc=1
50 fi
51 done
52
53 for f in $changed_text_files; do
54 if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then
55 echo "File $f doesn't use UTF-8, please convert it before committing." >&2
56 echo "(or set svn:mime-type property correctly if the file is binary)." >&2
57 rc=1
58 fi
59 done
60
61 exit $rc