forked from hyphanet/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify_indent.sh
executable file
·73 lines (67 loc) · 2 KB
/
verify_indent.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#
# A small script to verify 'indent only' commits server-side comparing the java bytecode
#
# Parameters: take the svn-revision number as its first parameter
# Author: Florent Daignière
# Year: 2007
RAND=$RANDOM
REPOSITORY="/var/freenet-svn/svn/"
REV=$1
PREVIOUSREV=$(( $REV - 1 ))
AUTHOR="$(svnlook author $REPOSITORY --revision $REV)"
JAVACOPT=" -source 1.5 -target 1.5 -nowarn -g:none"
CLASSPATH="/var/www/downloads/alpha/$(cat /var/www/downloads/alpha/.latest):/var/www/downloads/alpha/freenet-ext.jar"
if [[ $(svnlook info $REPOSITORY --revision $REV | grep -icE '^[ ]*[Ii]ndent(ing)?([ ])*(:|$)') -gt 0 ]]
then
mkdir $TMP/$RAND
cd $TMP/$RAND
touch ok nok
svnlook changed $REPOSITORY --revision $REV |awk '{print $2;}'|grep -iE .java$ > list
while read file
do
RESULT=0
FILENAME="$(echo $file|sed 's/.*\///g')"
mkdir "$RAND-$FILENAME" && cd "$RAND-$FILENAME"
mkdir orig && cd orig
svnlook cat $REPOSITORY "$file" --revision $PREVIOUSREV > "$FILENAME"
javac -classpath $CLASSPATH $JAVACOPT "$FILENAME"
RESULT=$(( $RESULT + $? ))
rm "$FILENAME"
cd ..
mkdir new && cd new
svnlook cat $REPOSITORY "$file" --revision $REV > "$FILENAME"
javac -classpath $CLASSPATH $JAVACOPT "$FILENAME"
RESULT=$(( $RESULT + $? ))
rm "$FILENAME"
cd ../
diff -Naurq orig new >> ../nok
if [[ $? -eq 0 ]]
then
for hash in $(find orig -type f -name \*class|sort)
do
sha1sum "$hash" |awk '{print $2 " : " $1;}' >> ../ok
done
else
for hash in $(find orig -type f -name \*class|sort)
do
echo $hash : $(sha1sum "$hash"|awk '{print $1;}') : $(sha1sum "${hash/orig/new}"|awk '{print $1;}') >> ../nok
done
fi
if [[ $RESULT -ne 0 ]]
then
echo "$FILENAME failed pre-compilation: we can't check whether it's a commit indent or not" >> ../nok
fi
cd ..
done <list
echo "$AUTHOR has declared that $REV is an 'indent only' commit:"
if test -s nok
then
echo -e "\tThat's FALSE.\n"
elif test -s list
then
echo -e "\tThat's TRUE.\n"
fi
cat ok nok
rm -r $TMP/$RAND
fi