aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/setup-hooks.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/setup-hooks.sh')
-rwxr-xr-xscripts/setup-hooks.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/setup-hooks.sh b/scripts/setup-hooks.sh
new file mode 100755
index 0000000..6913245
--- /dev/null
+++ b/scripts/setup-hooks.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
+
+script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
+script_dir="$( cd -- "$script_dir" && pwd )"
+
+cd -- "$script_dir"
+
+gitdir="$( git rev-parse --git-dir )"
+hooks_dir="$gitdir/hooks"
+
+symlink_dest="$( realpath "--relative-to=$hooks_dir" -- "$script_dir/pre-commit.sh" )"
+
+ln -fs -- "$symlink_dest" "$hooks_dir/pre-commit"