diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-13 00:11:21 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-13 00:11:21 +0200 |
| commit | 7f81b5305b4b125091a22f12f4547abe09fc2997 (patch) | |
| tree | 77b1507d901cd574353d31fbed601ebe18232237 /scripts/setup-hooks.sh | |
| parent | workflows/ci: windows-2025 ships with VS 2026 now (diff) | |
| download | math-server-7f81b5305b4b125091a22f12f4547abe09fc2997.tar.gz math-server-7f81b5305b4b125091a22f12f4547abe09fc2997.zip | |
add scripts to setup git hooks
Diffstat (limited to '')
| -rwxr-xr-x | scripts/setup-hooks.sh | 26 |
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 |
