]> git.saurik.com Git - wxWidgets.git/blob - misc/scripts/svn/hooks/pre-commit
Fix bug in the hook which prevented committing makefiles.
[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 svn_cat() {
9 $SVNLOOK cat "$REPOS" -t "$TXN" $1
10 }
11
12 all_changed_files=`$SVNLOOK changed "$REPOS" -t "$TXN" | \
13 grep "^[AU]" | \
14 sed 's/^....//'`
15
16 # notice that breaking all_changed_files into several lines by replacing spaces
17 # with new lines only works as long as we don't have any files with spaces in
18 # them -- which is the case for now, but if it ever changes we'd probably need
19 # to use a shell array for all_changed_files or just rerun svnlook here again
20 changed_sources=`echo $all_changed_files | \
21 sed 's/ /\n/g' | \
22 egrep "\.(cpp|h|py)$" | \
23 egrep -v "src/(tiff|regex|jpeg|stc/scintilla)"`
24
25 rc=0
26
27 set -e
28
29 for f in $changed_sources; do
30 if svn_cat $f | fgrep -q ' '; then
31 echo "Please remove TABs from $f before committing." >&2
32 rc=1
33 fi
34 done
35
36 for f in $all_changed_files; do
37 if ! svn_cat $f | iconv -f utf8 -t WCHAR_T > /dev/null; then
38 echo "File $f doesn't use UTF-8, please convert it before committing." >&2
39 rc=1
40 fi
41 done
42
43 exit $rc