-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·48 lines (44 loc) · 1.21 KB
/
install.sh
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
47
48
#!/bin/sh
cd "$(dirname $0)"
githooks="$PWD"
# Ignore githook repository.
project="$(dirname "$githooks")"
found=false
while [ "$found" = false ] && [ "$project" != '/' ]; do
# Can only connect to root of a git project.
if stat "$project/.git" >/dev/null 2>&1; then
echo "Link githooks to project '$(basename $project)'?"
select ans in 'yes' 'no' 'cancel'; do
case $ans in
yes )
found=true
break;;
no )
project="$(dirname "$project")"
break;;
cancel )
echo 'Canceled!'
exit 1
break;;
* )
echo 'Please select the number of your answer.'
echo
break;;
esac
done
else
project="$(dirname "$project")"
fi
done
if [ "$project" = '/' ]; then
echo 'No more projects to try!'
exit 1
fi
cd "$project/.git/hooks"
for hook in $githooks/hooks/* ; do
# Create relative symlinks.
hook="${hook/$project/../..}"
if [ -x "$hook" ]; then
ln -s "$hook" "$(basename "$hook")"
fi
done