perf: make pre-commit hooks pass file extensions

- shell-lint: faster evaluation of shell scripts, hook 40% faster;
- *-lint: unify method to find the "find" utility; and
- pre-commit: pass file extensions to lint tools.
This commit is contained in:
Ben Grande 2024-07-06 22:25:54 +02:00
parent 00a0b0f264
commit 35fa43dadf
No known key found for this signature in database
GPG key ID: 00C64E14F51F9E56
11 changed files with 65 additions and 82 deletions

View file

@ -7,19 +7,12 @@
# shellcheck disable=SC2086
set -eu
command -v git >/dev/null ||
{ printf "Missing program: git\n" >&2; exit 1; }
command -v git >/dev/null || { echo "Missing program: git" >&2; exit 1; }
cd "$(git rev-parse --show-toplevel)" || exit 1
./scripts/requires-program.sh mdl
extra_files_rules="~MD002,~MD012,~MD022,~MD032,~MD041"
find_tool="find"
if command -v fd; then
find_tool="fd"
elif command -v fdfind >/dev/null; then
find_tool="fdfind"
fi
find_tool="$(./scripts/best-program.sh fd fdfind find)"
if test -n "${1-}"; then
files=""