aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/setup-hooks.sh
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-12 22:52:32 +0200
committerEgor Tensin <egor@tensin.name>2026-06-12 22:52:32 +0200
commit847f4a6839838f2b9b547d67263103974ba92304 (patch)
tree76d99ec9ddcf9be7fa6b315a4259514e3b839cdc /scripts/setup-hooks.sh
parentworkflows/ci: windows-2025 ships with VS 2026 now (diff)
downloadwinapi-utf8-847f4a6839838f2b9b547d67263103974ba92304.tar.gz
winapi-utf8-847f4a6839838f2b9b547d67263103974ba92304.zip
add scripts to setup git hooks
Diffstat (limited to 'scripts/setup-hooks.sh')
-rwxr-xr-xscripts/setup-hooks.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/setup-hooks.sh b/scripts/setup-hooks.sh
new file mode 100755
index 0000000..dad7e79
--- /dev/null
+++ b/scripts/setup-hooks.sh
@@ -0,0 +1,26 @@
+#!/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 )"
+
+setup_clang_format_hook() {
+ local gitdir
+ gitdir="$( git rev-parse --git-dir )"
+ local hooks_dir
+ hooks_dir="$gitdir/hooks"
+
+ local symlink_dest
+ symlink_dest="$( realpath "--relative-to=$hooks_dir" -- "$script_dir/pre-commit.sh" )"
+
+ ln -fs -- "$symlink_dest" "$hooks_dir/pre-commit"
+}
+
+main() {
+ cd -- "$script_dir"
+ setup_clang_format_hook
+}
+
+main