.husky/prepare-commit-msg
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Check if detect-secrets is installed
if ! command -v detect-secrets &> /dev/null
then
echo "Warning: detect-secrets is not installed."
echo "!!! detect-secrets will not be run."
exit 0
fi
# Check if pyahocorasick is installed (word-list)
if ! python -c "import ahocorasick" &> /dev/null
then
echo "Warning: pyahocorasick is not installed."
echo "!!! detect-secrets will not be run."
exit 0
fi
# if there is no baseline, create one
if [ ! -e .secrets.baseline ]; then
echo "Creating baseline..."
detect-secrets scan --no-verify --word-list wordlist.txt > .secrets.baseline
fi
echo "Running detect-secrets on prepare-commit-msg..."
# Scans the commit message.
detect-secrets scan --no-verify --word-list wordlist.txt --string "$@" > /dev/null