Skip to content

Commit

Permalink
BATS: require shellcheck on test files
Browse files Browse the repository at this point in the history
BATS: add `*.bats` to `.gitattributes`
  • Loading branch information
gaelicWizard committed Mar 4, 2022
1 parent 3a77807 commit bf811cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion hooks/dot-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf811cd

Please sign in to comment.