Files
metabuilder/tools/pre-commit.hook
2025-12-25 16:00:00 +00:00

48 lines
1.5 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Pre-commit git hook for MetaBuilder
# Validates workflows before commits
# Install: cp scripts/pre-commit.hook .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}Pre-Commit Workflow Validation${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check if any workflow files were modified
if ! git diff --cached --name-only | grep -q '^\.github/workflows/'; then
echo " No workflow files changed, skipping validation"
exit 0
fi
# Run diagnostics if workflow files changed
echo -e "${YELLOW}Validating workflow files...${NC}"
if command -v ./scripts/diagnose-workflows.sh &> /dev/null; then
chmod +x scripts/diagnose-workflows.sh
./scripts/diagnose-workflows.sh
if [ $? -ne 0 ]; then
echo ""
echo -e "${YELLOW}⚠️ Workflow issues detected. Review above before committing.${NC}"
echo "To skip this check: git commit --no-verify"
exit 1
fi
else
echo "Diagnostic script not found, skipping workflow validation"
fi
echo ""
echo -e "${GREEN}✓ Pre-commit checks passed!${NC}"
echo ""
exit 0