Skip to content

Commit bf811cd

Browse files
committed
BATS: require shellcheck on test files
BATS: add `*.bats` to `.gitattributes`
1 parent 3a77807 commit bf811cd

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.sh text eol=lf
22
*.bash text eol=lf
3+
*.bats text eol=lf
34

45
# Docs allow trailing whitespaces
56
*.md whitespace=-blank-at-eol

.pre-commit-config.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ repos:
1919
hooks:
2020
- id: git-check # Configure in .gitattributes
2121
- id: shellcheck
22-
exclude: ".bats$"
2322
- id: shfmt
2423
exclude: ".bats$"
2524
- repo: https://github.com/Lucas-C/pre-commit-hooks
@@ -38,10 +37,9 @@ repos:
3837
types: [file]
3938
- id: dot-bash
4039
name: Check .bash files against bash-it requirements
41-
exclude: "test/test_helper.bash"
4240
entry: ./hooks/dot-bash.sh
4341
language: system
44-
files: "\\.bash$"
42+
files: "\\.ba[ts][sh]$"
4543
types: [file]
4644
- id: clean-files-txt
4745
name: Check that clean_files.txt is sorted alphabetically.

hooks/dot-bash.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ for file in "$@"; do
1212
# Confirm expected schellcheck header
1313
#
1414
LINE1="$(head -n 1 "${file}")"
15-
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
15+
SCSH="${file##*.}"
16+
if [[ "${LINE1}" != "# shellcheck shell=${SCSH}" ]]; then
1617
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
1718
exit_code=1
1819
fi

0 commit comments

Comments
 (0)