Created
January 28, 2026 22:01
-
-
Save NeftaliYagua/73e151e2dd4ca37e1a32be895241b7c3 to your computer and use it in GitHub Desktop.
Laravel Pint pre-commit hook - Corrección automática de código
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: Corregir y verificar código con Laravel Pint antes de commit | |
| # Si pint encuentra problemas, los corrige automáticamente y añade los cambios | |
| echo "🔧 Ejecutando Laravel Pint (corrección automática)..." | |
| if [ ! -f "vendor/bin/pint" ]; then | |
| echo "⚠️ WARNING: vendor/bin/pint no encontrado. Ejecuta 'composer install' primero." | |
| exit 0 # No bloquear si pint no está instalado | |
| fi | |
| # Ejecutar pint para corregir automáticamente | |
| vendor/bin/pint | |
| # Verificar si pint hizo cambios | |
| if [ $? -eq 0 ]; then | |
| # Verificar si hay cambios en el staging area | |
| if ! git diff --cached --quiet; then | |
| echo "✅ Laravel Pint: Correcciones aplicadas automáticamente" | |
| echo "📝 Los archivos corregidos han sido añadidos al staging area" | |
| # Añadir los archivos corregidos al staging area | |
| git add -u | |
| echo "✅ Archivos corregidos añadidos. Continuando con el commit..." | |
| else | |
| echo "✅ Laravel Pint: Sin correcciones necesarias" | |
| fi | |
| exit 0 | |
| else | |
| echo "" | |
| echo "❌ ERROR: Laravel Pint falló al ejecutarse." | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment