#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

exec 1>&2

echo "RUNNING PRE-COMMIT"

# Get list of files about to be committed
if git diff --cached --name-only --diff-filter=ACM | grep 'ccd_defs.json'; then
    echo "We changed ccd_defs.json"
    GIT_ROOT=$(git rev-parse --show-toplevel)
    perl $GIT_ROOT/ccd_defs_check.pl
fi

# non-zero exit fails the commit
exit 0
