BATS: require `shellcheck` on test files

BATS: add `*.bats` to `.gitattributes`
pull/2033/head
John D Pell 2022-01-12 00:02:52 -08:00 committed by John D Pell
parent 3a778072db
commit bf811cd38e
3 changed files with 4 additions and 4 deletions

1
.gitattributes vendored
View File

@ -1,5 +1,6 @@
*.sh text eol=lf
*.bash text eol=lf
*.bats text eol=lf
# Docs allow trailing whitespaces
*.md whitespace=-blank-at-eol

View File

@ -19,7 +19,6 @@ repos:
hooks:
- id: git-check # Configure in .gitattributes
- id: shellcheck
exclude: ".bats$"
- id: shfmt
exclude: ".bats$"
- repo: https://github.com/Lucas-C/pre-commit-hooks
@ -38,10 +37,9 @@ repos:
types: [file]
- id: dot-bash
name: Check .bash files against bash-it requirements
exclude: "test/test_helper.bash"
entry: ./hooks/dot-bash.sh
language: system
files: "\\.bash$"
files: "\\.ba[ts][sh]$"
types: [file]
- id: clean-files-txt
name: Check that clean_files.txt is sorted alphabetically.

View File

@ -12,7 +12,8 @@ for file in "$@"; do
# Confirm expected schellcheck header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
SCSH="${file##*.}"
if [[ "${LINE1}" != "# shellcheck shell=${SCSH}" ]]; then
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
exit_code=1
fi