-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpre-commit
More file actions
38 lines (34 loc) · 1.04 KB
/
Copy pathpre-commit
File metadata and controls
38 lines (34 loc) · 1.04 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
#!/bin/bash
# shellcheck disable=SC2154
# shellcheck disable=SC1090
# get functions and checks
if [ -L "$0" ]; then # $0 is symlink
while read -r line; do
source "$line"
done < <(find "$(dirname "$(readlink "$0")")/modules/" -type f -name '*.sh')
else
while read -r line; do
source "$line"
done < <(find "$(dirname "$0")/modules/" -type f -name '*.sh')
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_yaml_in_data 'data'
_puppet_git_hooks_check '\.pp$' 'puppet-lint --relative'
_puppet_git_hooks_check '\.pp$' '/opt/puppetlabs/bin/puppet parser validate'
_puppet_git_hooks_check '\.epp$' '/opt/puppetlabs/bin/puppet epp validate'
_puppet_git_hooks_check '\.yaml$' 'yamllint --strict'
_puppet_git_hooks_check '^Puppetfile$' 'r10k puppetfile check'
_puppet_git_hooks_check_trailing_whitespaces
# exit
if [ "$_rc" -eq '0' ]; then
echo
exit 0
else
echo
echo
echo 'git commit aborted.'
exit "$_rc"
fi