2013-09-17 10:34:45 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-03-12 16:05:28 +08:00
|
|
|
# change working dir to where this script resides in
|
|
|
|
pushd `dirname "$0"` > /dev/null
|
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
RESULT_SAVETO=`realpath $1`
|
|
|
|
fi
|
2013-09-17 10:34:45 +08:00
|
|
|
BASE_COMMIT=95a80f598fc57c60aed3737c60ee437d94eb8540
|
2015-03-12 16:05:28 +08:00
|
|
|
if [ -n "$2" ] && git log $2 > /dev/null 2>&1; then
|
|
|
|
BASE_COMMIT=$2
|
|
|
|
elif ! git log $BASE_COMMIT > /dev/null 2>&1; then
|
|
|
|
echo "No valid base commit found."
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-09-17 10:34:45 +08:00
|
|
|
LABS=`git diff $BASE_COMMIT --stat | grep -o "lab[0-9]" | uniq`
|
2015-03-12 16:05:28 +08:00
|
|
|
COMMIT=`git rev-parse HEAD`
|
2013-09-17 10:34:45 +08:00
|
|
|
|
|
|
|
if [ "$LABS" = "" ]; then
|
2015-03-12 16:05:28 +08:00
|
|
|
echo "No updated lab found. Skip."
|
2013-09-17 10:34:45 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
failed=0
|
|
|
|
|
|
|
|
pwd=`pwd`
|
|
|
|
summary=$pwd/.score_summary
|
|
|
|
|
|
|
|
echo -n > $summary
|
|
|
|
for lab in $LABS; do
|
|
|
|
pushd $lab > /dev/null
|
|
|
|
if ! make grade > .score 2>&1; then
|
|
|
|
failed=`echo $lab | grep -o [0-9]`
|
|
|
|
fi
|
2015-03-12 16:05:28 +08:00
|
|
|
if [ -n "$RESULT_SAVETO" ]; then
|
|
|
|
mkdir -p $RESULT_SAVETO/$COMMIT/$lab
|
|
|
|
mv .score .score_orig
|
|
|
|
../tools/split_score_log.py .score_orig > .score
|
|
|
|
for i in .*.log .*.error; do
|
|
|
|
cp $i $RESULT_SAVETO/$COMMIT/$lab/${i#.}
|
|
|
|
done
|
|
|
|
fi
|
2013-09-17 10:34:45 +08:00
|
|
|
score=`egrep -o "Score: [0-9]+/[0-9]+" .score`
|
|
|
|
echo "$lab $score" >> $summary
|
|
|
|
make clean > /dev/null
|
|
|
|
popd > /dev/null
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Labs with changes detected: " $LABS
|
|
|
|
echo
|
|
|
|
echo "============================== Summary =============================="
|
|
|
|
cat $summary
|
|
|
|
rm $summary
|
|
|
|
echo
|
|
|
|
|
|
|
|
for lab in $LABS; do
|
|
|
|
echo "================================ $lab ==============================="
|
|
|
|
cat $lab/.score
|
|
|
|
done
|
|
|
|
|
2015-03-12 16:05:28 +08:00
|
|
|
find . -name '.*' -delete
|
|
|
|
|
|
|
|
popd > /dev/null
|
|
|
|
|
2013-09-17 10:34:45 +08:00
|
|
|
exit $failed
|