-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·46 lines (39 loc) · 1.19 KB
/
install
File metadata and controls
executable file
·46 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#====================================================================
# Run ./install inside a git repositories root directory and follow
# the prompts.
#====================================================================
# enable user input
exec < /dev/tty
# Skip non-git directories
if [ ! -d "${PWD}/.git" ]; then
echo "Current directory does not contain a .git directory!"
exit 1;
fi
# FIXME allow setting INSTALL_ALL from outside this script
INSTALL_ALL=0
SCRIPT_DIR=$(dirname "$(stat -f "$0")")
HOOKS=(
"post-checkout"
"post-merge"
"pre-commit"
)
for hook in ${HOOKS[@]}; do
working_hook_dir="${PWD}/.git/hooks/$hook.d"
mkdir -p $working_hook_dir
cp -i "$SCRIPT_DIR/base-hook" "${PWD}/.git/hooks/$hook"
for filename in $SCRIPT_DIR/$hook.d/*; do
should_install=0
# Prompt for isntall if we are not isntall all hooks
if [ $INSTALL_ALL -eq 0 ]; then
read -p "Install $filename? (y/n) [y] " response
if [[ $response =~ ^(yes|y|Y| ) ]] || [[ -z $response ]]; then
should_install=1
fi
fi
if [ $should_install -eq 1 ] || [ $INSTALL_ALL -eq 1 ]; then
# Install hook
cp -f $filename "$working_hook_dir/"
fi
done
done