File: spellchecker

package info (click to toggle)
mpich 4.3.0%2Breally4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 419,120 kB
  • sloc: ansic: 1,215,557; cpp: 74,755; javascript: 40,763; f90: 20,649; sh: 18,463; xml: 14,418; python: 14,397; perl: 13,772; makefile: 9,279; fortran: 8,063; java: 4,553; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (66 lines) | stat: -rwxr-xr-x 1,780 bytes parent folder | download | duplicates (3)
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