forked from pengutronix/umpf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
executable file
·28 lines (22 loc) · 719 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
#!/bin/sh
#
# A git pre-commit hook script to make sure no new shellcheck warnings are
# introduced.
# Redirect output to stderr.
exec 1>&2
if [ ! -e /usr/bin/shellcheck ]; then
cat <<EOF
Error: Commit aborted in pre-commit hook due to missing shellcheck.
Please install shellcheck to use this hook.
EOF
exit 1
fi
# We ignore the check SC2155 "Declare and assign separately to avoid masking
# return values", as this reduced legibility and return values are ignored.
if ! shellcheck -S warning -e SC2155 umpf; then
cat <<EOF
Error: Commit aborted in pre-commit hook due to shellcheck warnings.
Please make sure "shellcheck -S warning -e SC2155 umpf" reports no warnings before trying to commit.
EOF
exit 1
fi