aboutsummaryrefslogtreecommitdiff
path: root/.hooks/pre-commit.d
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.d
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.d')
-rwxr-xr-x.hooks/pre-commit.d/check_category_makefile17
1 files changed, 17 insertions, 0 deletions
diff --git a/.hooks/pre-commit.d/check_category_makefile b/.hooks/pre-commit.d/check_category_makefile
new file mode 100755
index 000000000000..fb43d4353256
--- /dev/null
+++ b/.hooks/pre-commit.d/check_category_makefile
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Check that ports are hooked into the build
+#
+
+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
+ if [ $? -ne 0 ] ; then
+ echo "[pre-commit] ERROR: Missing 'SUBDIR += ${port}' in ${category}/Makefile"
+ exit 1
+ fi
+ done
+fi