]> git.saurik.com Git - wxWidgets.git/blame - misc/scripts/svn/hooks/pre-commit
commenting never used code
[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
18all_changed_files=`svnl changed | \
078a94e0 19 grep "^[AU]" | \
0126e6d2 20 sed 's/^....//' | \
3347f618 21 egrep -v "src/(tiff|regex|jpeg|stc/scintilla)"`
078a94e0 22
0126e6d2
VZ
23# analyze the changed files to find all non-binary and all source files
24for 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
44done
3347f618
VZ
45
46for f in $changed_sources; do
0126e6d2 47 if svnl cat $f | fgrep -q ' '; then
078a94e0
VZ
48 echo "Please remove TABs from $f before committing." >&2
49 rc=1
50 fi
51done
52
0126e6d2
VZ
53for f in $changed_text_files; do
54 if ! svnl cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then
3347f618 55 echo "File $f doesn't use UTF-8, please convert it before committing." >&2
0126e6d2 56 echo "(or set svn:mime-type property correctly if the file is binary)." >&2
3347f618
VZ
57 rc=1
58 fi
59done
60
078a94e0 61exit $rc