-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpre-commit
35 lines (31 loc) · 975 Bytes
/
pre-commit
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
#!/bin/bash
# get functions and checks
if [ -L $0 ]; then # $0 is symlink
for i in $(find $(dirname $(readlink $0))/modules/ -type f -name '*.sh' ); do
source $i
done
else
for i in $(find $(dirname $0)/modules/ -type f -name '*.sh' ); do
source $i
done
fi
# collect changed files
_puppet_git_hooks_git_init
# do checks
#_puppet_git_hooks_check '\.erb$' 'bash -c "erb -x -T - $@ | ruby -c"' ${_files} # not working
_puppet_git_hooks_check '\.pp$' 'puppet-lint --relative' ${_files}
_puppet_git_hooks_check '\.pp$' '/opt/puppetlabs/bin/puppet parser validate' ${_files}
_puppet_git_hooks_check '\.epp$' '/opt/puppetlabs/bin/puppet epp validate' ${_files}
_puppet_git_hooks_check '\.yaml$' 'yamllint --strict' ${_files}
_puppet_git_hooks_check '^Puppetfile$' 'r10k puppetfile check' ${_files}
_puppet_git_hooks_check_trailing_whitespaces ${_files}
# exit
if [ $_rc -eq 0 ]; then
echo
exit 0
else
echo
echo
echo 'git commit aborted.'
exit $_rc
fi