summaryrefslogtreecommitdiff
path: root/git-hooks/install.sh
blob: 17d59bc62051b5d03f07bba44092058838fa87f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

set -e

githooks_dir="$(git rev-parse --git-dir)"
for hook in hooks/*; do
    hook="${hook#hooks/}"
    if [ -f "$githooks_dir/hooks/$hook" ]; then
        mv "$githooks_dir/hooks/$hook" "$githooks_dir/hooks/own_$hook"
    fi

    echo '#!/bin/sh
        exec "$(git rev-parse --git-dir)/../git-hooks/loader.sh" '"$hook"' "$@"
    ' > "$githooks_dir/hooks/$hook"
    chmod +x "$githooks_dir/hooks/$hook"
done