Allow for ocaml-typo=prune

master
David Allsopp 2018-06-30 16:54:47 +01:00
parent 5af8d6d946
commit 3f8c68b9d4
2 changed files with 44 additions and 4 deletions

View File

@ -157,6 +157,24 @@ EOF
testsuite > /dev/null && exit 1 || echo pass
}
# Test to see if any part of the directory name has been marked prune
not_pruned () {
DIR=$(dirname "$1")
if [ "$DIR" = "." ] ; then
return 0
else
case ",$(git check-attr ocaml-typo "$DIR" | sed -e 's/.*: //')," in
,prune,)
return 1
;;
*)
not_pruned $DIR
return $?
esac
fi
}
CheckTypoTree () {
export OCAML_CT_HEAD=$1
export OCAML_CT_LS_FILES="git diff-tree --no-commit-id --name-only -r $2 --"
@ -166,9 +184,13 @@ CheckTypoTree () {
git diff-tree --diff-filter=d --no-commit-id --name-only -r $1 \
| (while IFS= read -r path
do
echo "Checking $1: $path"
if ! tools/check-typo $path ; then
touch check-typo-failed
if not_pruned $path ; then
echo "Checking $1: $path"
if ! tools/check-typo $path ; then
touch check-typo-failed
fi
else
echo "NOT checking $1: $path (ocaml-typo=prune)"
fi
done)
rm -f tmp-index

View File

@ -45,6 +45,24 @@ if ! git diff-index --check --cached $against -- $FILES ; then
exit 1
fi
# Test to see if any part of the directory name has been marked prune
not_pruned () {
DIR=$(dirname "$1")
if [ "$DIR" = "." ] ; then
return 0
else
case ",$(git check-attr ocaml-typo "$DIR" | sed -e 's/.*: //')," in
,prune,)
return 1
;;
*)
not_pruned $DIR
return $?
esac
fi
}
# Now run check-typo over all the files in the index
ERRORS=0
export OCAML_CT_PREFIX=:
@ -52,7 +70,7 @@ export OCAML_CT_CAT="git cat-file --textconv"
export OCAML_CT_CA_FLAG=--cached
git diff --diff-filter=d --staged --name-only | (while IFS= read -r path
do
if ! tools/check-typo $path ; then
if not_pruned $path && ! tools/check-typo $path ; then
ERRORS=1
fi
done; exit $ERRORS)