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
|
#! /usr/bin/env bash
##
## Copyright (C) by Argonne National Laboratory
## See COPYRIGHT in top-level directory
##
# This script is used for CI testing, to use --
# git rebase --verbose --exec maint/hooks/spellchecker [base-commit]
# Redirect output to stderr.
exec 1>&2
MIRROR=/tmp/${USER}/mpich-spellchecker-$$
TMP_FILENAME=/tmp/${USER}/mpich-tmp-$$
# Checkout a copy of the current index into MIRROR
git checkout-index --prefix=$MIRROR/ -af
# Remove files from MIRROR which are no longer present in the index
git diff-index --cached --name-only --diff-filter=D -z HEAD | \
(cd $MIRROR && xargs -0 rm -f --)
# This will check the previous commit again when not amending a commit, but that
# should be ok if the patches are correct.
filestring=`git diff --cached --name-only --diff-filter=ACM HEAD~1`
# Everything else happens in the temporary build tree
pushd $MIRROR > /dev/null
ret=0
# check commit message
git log --format=%B -n 1 HEAD > commit-message
cp commit-message ${TMP_FILENAME}
bash maint/spellcheck.sh commit-message
diff commit-message ${TMP_FILENAME}
if [ $? != 0 ] ; then
ret=1
fi
rm -f commit-message
# This won't work if we ever have a file with a space in the name
for file in $filestring
do
if [[ -f $file && $file != *.tex ]]; then
cp -p ${file} ${TMP_FILENAME}
output=$(bash maint/spellcheck.sh ${file})
diffs=$(git --no-pager diff ${file} ${TMP_FILENAME})
if test -n "$output" -o -n "$diffs" ; then
echo "$output"
echo "$diffs"
ret=1
fi
fi
done
popd > /dev/null
rm -rf ${MIRROR} ${TMP_FILENAME}
if [ $ret != 0 ] ; then
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${RED}== SPELLCHECKER SCRIPT FAILED ==${NC}"
exit $ret
fi
|