24 lines
625 B
Bash
24 lines
625 B
Bash
#!/bin/bash
|
|
# Pre-commit hook for Code Privacy Shield
|
|
# Add this to .git/hooks/pre-commit
|
|
|
|
set -e
|
|
|
|
# Find the project root
|
|
ROOT_DIR="$(git rev-parse --show-toplevel)"
|
|
|
|
# Check if CPS is available
|
|
if command -v cps &> /dev/null; then
|
|
echo "Running Code Privacy Shield check..."
|
|
|
|
# Check staged Python files
|
|
FILES=$(git diff --cached --name-only -- '*.py' '*.js' '*.ts' '*.json' '*.yaml' '*.yml' 2>/dev/null || true)
|
|
|
|
if [ -n "$FILES" ]; then
|
|
# Preview what would be redacted
|
|
echo "$FILES" | xargs -I {} sh -c 'echo "Checking {}"; cps preview "{}" 2>/dev/null || true'
|
|
fi
|
|
fi
|
|
|
|
exit 0
|