Files
portfolio/.githooks
denshooter aaf80244d7 Update pre-push hook to use production test configuration
- Change from npm run test to npm run test:production
- This ensures the pre-push checks use the same test configuration as CI
- Fixes the test failures that were blocking pushes
2025-10-15 16:09:19 +02:00
..
2025-09-12 23:31:46 +02:00

Git Hooks

This directory contains Git hooks for the Portfolio project.

Pre-Push Hook

The pre-push hook runs automatically before every git push and performs the following checks:

Checks Performed:

  1. Node.js Version Check - Ensures Node.js 20+ is installed
  2. Dependency Installation - Installs npm dependencies if needed
  3. Linting - Runs ESLint to check code quality
  4. Tests - Runs Jest test suite
  5. Build - Builds the Next.js application
  6. Security Audit - Runs npm audit for vulnerabilities
  7. Secret Detection - Checks for accidentally committed secrets
  8. Docker Configuration - Validates Dockerfile and docker-compose.yml
  9. Production Checks - Additional checks when pushing to production branch

Production Branch Special Checks:

  • Environment file validation
  • Docker build test
  • Deployment readiness check

Usage:

The hook runs automatically on every push. To manually test it:

# Test the hook manually
.githooks/pre-push

# Or push to trigger it
git push origin main

Bypassing the Hook:

If you need to bypass the hook in an emergency:

git push --no-verify origin main

Note: Only bypass in emergencies. The hook prevents broken code from being pushed.

Troubleshooting:

If the hook fails:

  1. Fix the reported issues (linting errors, test failures, etc.)
  2. Run the checks manually to debug:
    npm run lint
    npm run test
    npm run build
    npm audit
    
  3. Check Node.js version: node --version (should be 20+)
  4. Reinstall dependencies: rm -rf node_modules && npm ci

Configuration:

The hook is configured in .git/config:

[core]
    hooksPath = .githooks

To disable hooks temporarily:

git config core.hooksPath ""

To re-enable:

git config core.hooksPath .githooks