Page MenuHomeFreeBSD

D37387.diff
No OneTemporary

D37387.diff

diff --git a/.hooks/pre-commit.d/check_files b/.hooks/pre-commit.d/check_files
new file mode 100755
--- /dev/null
+++ b/.hooks/pre-commit.d/check_files
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Check that only standard files are added to a port
+#
+# .*\.mk
+# Makefile.*
+# distinfo.*
+# pkg-.*
+#
+
+category_regex="($(make -VSUBDIR | sed 's# #\|#g'))"
+newish_files=$(git diff --name-only --cached --diff-filter=ACR | grep -E "^${category_regex}/[^/]+/[^/]+$")
+
+status=0
+if [ $? -eq 0 ] ; then
+ for newish_file in ${newish_files} ; do
+ category=$(echo "${newish_file}" | awk -F '/' '{print $1}')
+ port=$(echo "${newish_file}" | awk -F '/' '{print $2}')
+ file=$(echo "${newish_file}" | awk -F '/' '{print $3}')
+ valid=$(echo "${file}" | grep -q '^((Makefile|distinfo|pkg-)(.*))|(.*\.mk)$')
+ if [ $? -ne 0 ] ; then
+ echo "[pre-commit] ERROR: invalid file '${file}' in '${category}/${port}'"
+ status=1
+ fi
+ done
+fi
+if [ ${status} -eq 1 ] ; then
+ echo " Consider moving non-standard files to files/ or force-ignore this hook."
+ exit 1
+fi

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 1, 12:17 PM (1 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28363353
Default Alt Text
D37387.diff (1 KB)

Event Timeline