#!/usr/bin/env bash

# Exit on first failure.
set -e

# Exit on unset variable.
set -u

# Echo commands before executing them, by default to stderr.
set -x

# Change directory to repository root.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
cd "${SCRIPT_DIR}/.."

# If there's an existing symlink, remove it.
if [[ -L .git/hooks ]]
then
  rm .git/hooks
fi

# If it's a regular directory, remove all files.
if [[ -d .git/hooks ]]
then
  rm -rf .git/hooks
fi

ln --symbolic --force ../dev-scripts/git-hooks .git/hooks
