-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-hooks.sh
executable file
·52 lines (46 loc) · 964 Bytes
/
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
#!/bin/bash
GIT_FOLDER=`git rev-parse --git-dir`/hooks
SRC_FOLDER=./scripts/git-hooks
function print_usage()
{
echo -e "Usage: $(basename $0) [COMMAND]"
echo -e ""
echo -e "Commands:"
echo -e " install Install ${GIT_FOLDER}/precommit"
echo -e " uninstall Uninstall ${GIT_FOLDER}/pre-commit"
echo -e " run Run ${SRC_FOLDER}/pre-commit.sh"
echo -e ""
}
function do_install()
{
echo "cp $SRC_FOLDER/pre-commit.sh $GIT_FOLDER/pre-commit"
cp $SRC_FOLDER/pre-commit.sh $GIT_FOLDER/pre-commit
exit 0
}
function do_uninstall()
{
echo "rm $GIT_FOLDER/pre-commit"
rm $GIT_FOLDER/pre-commit
exit 0
}
function do_run()
{
$SRC_FOLDER/pre-commit.sh
exit 0
}
# Parsing dei parametri ricevuti sulla stringa di comando
for i in "$@"; do
case "$i" in
install)
do_install ${@/$i}
;;
uninstall)
do_uninstall ${@/$i}
;;
run)
do_run ${@/$i}
;;
esac
done
print_usage
exit 0