mirror of
https://git.freebsd.org/ports.git
synced 2025-04-29 01:56:37 -04:00
framework: create a sub-directory to support multiple pre-commit hooks
This commit is contained in:
parent
aa25396790
commit
4e21a051bb
2 changed files with 25 additions and 10 deletions
|
@ -1,17 +1,15 @@
|
||||||
#!/bin/sh
|
#!/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$')
|
hook_directory=$(realpath $(dirname $0))
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
for newish_makefile in ${newish_makefiles} ; do
|
for hook in ${hook_directory}/pre-commit.d/* ; do
|
||||||
category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}')
|
if [ -x "${hook}" ] ; then
|
||||||
port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}')
|
${hook}
|
||||||
grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile
|
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "[pre-commit] ERROR: Missing 'SUBDIR += ${port}' in ${category}/Makefile"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
fi
|
done
|
||||||
|
|
17
.hooks/pre-commit.d/check_category_makefile
Executable file
17
.hooks/pre-commit.d/check_category_makefile
Executable file
|
@ -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
|
Loading…
Add table
Reference in a new issue