Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gnuton committed Jan 10, 2025
1 parent 20236c0 commit 96b4929
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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

0 comments on commit 96b4929

Please sign in to comment.