Skip to content

Commit 629eb30

Browse files
committed
Add support for linting shell script files pre-commit
1 parent a5eb209 commit 629eb30

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools/git/hooks/pre-commit

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ run_lint() {
203203
fi
204204
fi
205205

206+
# Lint shell script files...
207+
files=$(echo "${changed_files}" | while read -r file; do head -n1 "$file" | grep -q '^\#\!/usr/bin/env bash' && echo "$file"; done | tr '\n' ' ')
208+
if [[ -n "${files}" ]]; then
209+
make check-shell-linters > /dev/null >&2
210+
if [[ "$?" -ne 0 ]]; then
211+
echo '' >&2
212+
echo 'Unable to lint shell script files. Ensure that linters are installed.' >&2
213+
else
214+
make FILES="${files}" lint-shell-files > /dev/null >&2
215+
if [[ "$?" -ne 0 ]]; then
216+
echo '' >&2
217+
echo 'Shell script lint errors.' >&2
218+
return 1
219+
fi
220+
fi
221+
fi
222+
206223
# Lint license headers...
207224
files=$(echo "${changed_files}" | tr '\n' ' ')
208225
if [[ -n "${files}" ]]; then

0 commit comments

Comments
 (0)