mirror of
https://github.com/gnuton/asuswrt-merlin.ng.git
synced 2025-05-10 22:32:15 +02:00
tools: Add pre-hook script
This commit is contained in:
parent
2a1834aad2
commit
c5e2d877be
2 changed files with 38 additions and 0 deletions
28
scripts/hooks/pre-commit
Executable file
28
scripts/hooks/pre-commit
Executable file
|
@ -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
|
10
scripts/install-hooks.sh
Executable file
10
scripts/install-hooks.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
REPO_BASE=$(git rev-parse --show-toplevel)
|
||||
SCRIPT_DIR="$REPO_BASE/scripts/hooks"
|
||||
INSTALL_DIR="$REPO_BASE/.git/hooks"
|
||||
|
||||
echo "Repository base directory:$REPO_BASE"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cp -a "${SCRIPT_DIR}"/* "${INSTALL_DIR}"
|
||||
echo "All webhooks have been copied"
|
Loading…
Add table
Add a link
Reference in a new issue