23 lines
575 B
Bash
23 lines
575 B
Bash
#!/bin/bash
|
|
|
|
root=$(git rev-parse --show-toplevel)
|
|
preCommitFile=$HOME/.config/git/global_hooks/pre-commit
|
|
echo "root dir: $root"
|
|
|
|
echo "enabled hooks: "
|
|
for f in "$root/.git/hooks"/*; do
|
|
if [[ ${f: -7} != ".sample" ]]; then
|
|
echo " $(basename "$f")"
|
|
fi
|
|
done
|
|
|
|
if [[ -L "$root/.git/hooks/pre-commit" ]]; then
|
|
echo "pre-commit already linked"
|
|
elif [[ -f "$root/.git/hooks/pre-commit" ]]; then
|
|
echo "pre-commit already exists as regular file"
|
|
else
|
|
echo "linking pre-commit $preCommitFile"
|
|
ln -s "$preCommitFile" "$root/.git/hooks/pre-commit"
|
|
fi
|
|
|