asuswrt-merlin.ng/scripts/hooks/pre-commit
2025-01-11 00:41:00 +01:00

28 lines
699 B
Bash
Executable file

#!/bin/bash
echo "Checking source file for broadcom proprietary files..."
pattern1='BRCM:[0-9]+:proprietary:'
pattern2='BRCM:[0-9]+:NONE:RED'
files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(c|h)$')
if [ -z "$files" ]; then
# No .c or .h files staged, exit successfully
exit 0
fi
echo "Checking files:"
for file in $files; do
echo "* $file"
if git show ":$file" | grep -Eq "$pattern1|$pattern2"; then
echo "Error: File '$file' contains forbidden patterns."
echo "Patterns:"
echo " - $pattern1"
echo " - $pattern2"
echo "Commit aborted."
exit 1
fi
done
# If no matches are found, allow the commit
exit 0