forked from freebsd/freebsd-ports
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
framework: create a sub-directory to support multiple pre-commit hooks
- Loading branch information
Showing
2 changed files
with
25 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |