aboutsummaryrefslogtreecommitdiff
path: root/.hooks/pre-commit
diff options
context:
space:
mode:
authorTobias C. Berner <tcberner@FreeBSD.org>2022-04-24 10:11:13 +0000
committerTobias C. Berner <tcberner@FreeBSD.org>2022-04-24 10:24:28 +0000
commit4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578 (patch)
tree09cb05ffc36649eb4f902eb33428461857b873d4 /.hooks/pre-commit
parentaa2539679084872cd84112e9df6bfee571570623 (diff)
downloadports-4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578.tar.gz
ports-4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578.zip
framework: create a sub-directory to support multiple pre-commit hooks
Diffstat (limited to '.hooks/pre-commit')
-rwxr-xr-x.hooks/pre-commit18
1 files changed, 8 insertions, 10 deletions
diff --git a/.hooks/pre-commit b/.hooks/pre-commit
index fb43d4353256..886d97d7cc1b 100755
--- a/.hooks/pre-commit
+++ b/.hooks/pre-commit
@@ -1,17 +1,15 @@
#!/bin/sh
#
-# Check that ports are hooked into the build
+# Runs every hook in pre-commit.d/ until the first failure
#
-newish_makefiles=$(git diff --name-only --cached --diff-filter=ACR | grep -E '^[^/]+/[^/]+/Makefile$')
-if [ $? -eq 0 ] ; then
- for newish_makefile in ${newish_makefiles} ; do
- category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}')
- port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}')
- grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile
+hook_directory=$(realpath $(dirname $0))
+
+for hook in ${hook_directory}/pre-commit.d/* ; do
+ if [ -x "${hook}" ] ; then
+ ${hook}
if [ $? -ne 0 ] ; then
- echo "[pre-commit] ERROR: Missing 'SUBDIR += ${port}' in ${category}/Makefile"
exit 1
fi
- done
-fi
+ fi
+done