mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
24 lines
875 B
Bash
Executable File
24 lines
875 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
HOOK_NAMES=(pre-push)
|
|
|
|
TOP_DIR=$(git rev-parse --show-toplevel)
|
|
HOOK_DIR=$TOP_DIR/.git/hooks
|
|
REPO_HOOKS=$TOP_DIR/dev-env/git-hooks
|
|
|
|
for hook in "${HOOK_NAMES[@]}"; do
|
|
# If the hook already exists, is executable, and is not a symlink
|
|
if [[ ! -h "$HOOK_DIR/$hook" && -x "$HOOK_DIR/$hook" ]]; then
|
|
echo "Saving local $HOOK_DIR/$hook hook"
|
|
mv "$HOOK_DIR/$hook" "$HOOK_DIR/$hook.local"
|
|
fi
|
|
# create the symlink, overwriting the file if it exists
|
|
# probably the only way this would happen is if you're using an old version of git
|
|
# -- back when the sample hooks were not executable, instead of being named ____.sample
|
|
# we link all hooks to the wrapper, so we could also invoke .local hooks
|
|
echo "Installing $HOOK_DIR/$hook hook"
|
|
ln -s -f "$REPO_HOOKS/hook-wrapper" "$HOOK_DIR/$hook"
|
|
done
|