-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_hooks
More file actions
executable file
·60 lines (50 loc) · 1.1 KB
/
Copy pathcustom_hooks
File metadata and controls
executable file
·60 lines (50 loc) · 1.1 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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Path to hooks
hooks_path="/usr/local/src/git-hooks/hooks"
# Get infos from stdin
read oldrev newrev refname
# Colors for nice output
Normal='\e[0m'
Green='\e[0;32m'
Yellow='\e[0;33m'
Red='\e[0;31m'
ORIGINAL_IFS=$IFS
STATUS=true
affected_files()
{
for extension in ${@}
do
for comitted_file in $( git diff-tree -r ${oldrev}..${newrev} | awk {'print substr($0, index($0,$6))'} )
do
if [ "${comitted_file##*.}" = "$extension" ]
then
echo "$comitted_file"
fi
done
done
}
commited_file()
{
sourcefile="${1}"
git show ${newrev}:"${sourcefile}"
}
# load local dot hooks (e.g. local update.gitolite)
for local_hook in $( ls hooks/$( basename ${0} ).* 2> /dev/null )
do
echo "${oldrev}" "${newrev}" "${refname}" < ${local_hook}
if [ $? != 0 ]
then
STATUS=false
exit 1
fi
done
# load available custom hooks
for custom_hook in $( ls "${hooks_path}/"$( basename ${0} ).* 2> /dev/null )
do
. "${custom_hook}"
if [ $? != 0 ]
then
STATUS=false
fi
done
${STATUS}