Created
December 1, 2025 13:14
-
-
Save hkraji/410956ed07e7ae3d0ee3c0198b27430d to your computer and use it in GitHub Desktop.
Pipeline CRM pre-commit hook for structure.sql protection
This file contains hidden or 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
| #!/bin/bash | |
| # Pre-commit hook to warn about large changes to db/structure.sql | |
| STRUCTURE_FILE="db/structure.sql" | |
| THRESHOLD=200 | |
| # Check if structure.sql is staged for commit | |
| if git diff --cached --name-only | grep -q "^${STRUCTURE_FILE}$"; then | |
| # Count the number of changed lines (additions + deletions) | |
| CHANGES=$(git diff --cached --numstat "$STRUCTURE_FILE" | awk '{print $1 + $2}') | |
| if [ "$CHANGES" -gt "$THRESHOLD" ]; then | |
| echo "" | |
| echo "⚠️ WARNING: Large changes detected in $STRUCTURE_FILE" | |
| echo " $CHANGES lines changed (threshold: $THRESHOLD)" | |
| echo "" | |
| echo " Remember: Pipeline CRM uses manual structure.sql maintenance." | |
| echo " Make sure you're not committing auto-generated changes." | |
| echo "" | |
| # Check if we're in an interactive terminal | |
| if [ -t 0 ]; then | |
| read -p "Do you want to proceed with this commit? (y/N) " -n 1 -r | |
| echo "" | |
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
| echo "Commit aborted." | |
| exit 1 | |
| fi | |
| else | |
| echo " Non-interactive mode: Set SKIP_STRUCTURE_CHECK=1 to bypass." | |
| echo "" | |
| if [ "$SKIP_STRUCTURE_CHECK" != "1" ]; then | |
| echo "Commit aborted. Run with SKIP_STRUCTURE_CHECK=1 to bypass." | |
| exit 1 | |
| fi | |
| fi | |
| fi | |
| fi | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment