Debian Codegraph @

maint/hooks/spellchecker

raw symbols SCIP
1 #! /usr/bin/env bash
2 ##
3 ## Copyright (C) by Argonne National Laboratory
4 ## See COPYRIGHT in top-level directory
5 ##
6
7 # This script is used for CI testing, to use --
8 # git rebase --verbose --exec maint/hooks/spellchecker [base-commit]
9
10 # Redirect output to stderr.
11 exec 1>&2
12
13 MIRROR=/tmp/${USER}/mpich-spellchecker-$$
14 TMP_FILENAME=/tmp/${USER}/mpich-tmp-$$
15
16 # Checkout a copy of the current index into MIRROR
17 git checkout-index --prefix=$MIRROR/ -af
18
19 # Remove files from MIRROR which are no longer present in the index
20 git diff-index --cached --name-only --diff-filter=D -z HEAD | \
21 (cd $MIRROR && xargs -0 rm -f --)
22
23 # This will check the previous commit again when not amending a commit, but that
24 # should be ok if the patches are correct.
25 filestring=`git diff --cached --name-only --diff-filter=ACM HEAD~1`
26
27 # Everything else happens in the temporary build tree
28 pushd $MIRROR > /dev/null
29
30 ret=0
31
32 # check commit message
33 git log --format=%B -n 1 HEAD > commit-message
34 cp commit-message ${TMP_FILENAME}
35 bash maint/spellcheck.sh commit-message
36 diff commit-message ${TMP_FILENAME}
37 if [ $? != 0 ] ; then
38 ret=1
39 fi
40 rm -f commit-message
41
42 # This won't work if we ever have a file with a space in the name
43 for file in $filestring
44 do
45 if [[ -f $file && $file != *.tex ]]; then
46 cp -p ${file} ${TMP_FILENAME}
47 output=$(bash maint/spellcheck.sh ${file})
48 diffs=$(git --no-pager diff ${file} ${TMP_FILENAME})
49 if test -n "$output" -o -n "$diffs" ; then
50 echo "$output"
51 echo "$diffs"
52 ret=1
53 fi
54 fi
55 done
56
57 popd > /dev/null
58
59 rm -rf ${MIRROR} ${TMP_FILENAME}
60
61 if [ $ret != 0 ] ; then
62 RED='\033[0;31m'
63 NC='\033[0m' # No Color
64 echo -e "${RED}== SPELLCHECKER SCRIPT FAILED ==${NC}"
65 exit $ret
66 fi