#!/bin/sh # # Set up a clone of the security-tracker git repo set -e SRC=../../conf/pre-commit HOOK=.git/hooks/pre-commit install_pre_commit_hook() { if [ -L "${HOOK}" ] && [ "$(readlink ${HOOK})" = "${SRC}" ]; then echo "pre-commit hook already set up" return fi if [ -e "${HOOK}" ] || [ -L "${HOOK}" ]; then echo "Moving old pre-commit hook" mv -f "${HOOK}" "${HOOK}.$(date '+%s')" fi echo "Installing pre-commit hook" ln -s "${SRC}" "${HOOK}" } if [ "$(git rev-parse --show-cdup)" != '' ] || [ -d data/CVE/list ]; then echo "This does not look like the git repo of the security tracker" 1>&2 exit 1 fi install_pre_commit_hook