forked from ckrf/xlsx-git
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-git-hooks.sh
54 lines (40 loc) · 1.16 KB
/
install-git-hooks.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
49
50
51
52
53
54
#!/bin/bash
DIR=$(pwd);
cd .git/hooks
echo "=== Starting git hooks installation ======="
# Create link for every git hook in the folder
echo ' Installing git hooks in' $(pwd)
for i in $(ls $DIR/git/hooks/); do
new_link_file=$DIR/git/hooks/$i
# Overwrite any existing git hooks with the same name
ln -sf $DIR/git/hooks/$i . && echo " $i link created"
done
echo "=== Git hooks installation finish ========="
echo "=== Checking if commands are installed ===="
command_exists () {
type "$1" &> /dev/null ;
}
all_commands_installed=true
install_command=" sudo apt install "
if ! (command_exists unzip && command_exists zip) ; then
install_command+="zip unzip "
$all_commands_installed=false
fi
if ! command_exists jq ; then
install_command+="jq "
$all_commands_installed=false
fi
if ! command_exists xmllint ; then
install_command+="libxml2-utils "
all_commands_installed=false
fi
if ! $all_commands_installed ; then
echo " ERROR: Please install missing commands:"
echo $install_command
echo
exit 1
fi
echo "=== Commands installed, everything's ok ==="
echo "=== Running post-commit to unpack reports ="
cd - &> /dev/null
./.git/hooks/post-commit