Skip to main content

CODITECT Pre-commit Hook Script

================================ STATUS: STUB - Not yet implemented VERSION: 0.1.0 (placeholder) AUTHOR: CODITECT Core Team DESCRIPTION: Git pre-commit hook that runs quality checks before allowing commits. Validates code quality, formatting, and security before changes are committed. PURPOSE:

  • Run linters on staged files
  • Check code formatting
  • Detect secrets/credentials
  • Validate commit message format
  • Run fast unit tests
  • Prevent commits with issues USAGE: Installed as .git/hooks/pre-commit Or run directly: ./scripts/pre-commit-hook.sh OPTIONS: -h, --help Show this help message --skip-tests Skip test execution --skip-format Skip formatting checks --skip-secrets Skip secrets detection --fix Attempt to auto-fix issues IMPLEMENTATION REQUIREMENTS:
  1. Staged file detection
  2. Language-specific linter execution
  3. Formatting check (black, prettier, rustfmt)
  4. Secrets scanning (gitleaks, detect-secrets)
  5. Fast test subset execution
  6. Auto-fix capability
  7. Bypass mechanism for emergencies CHECKS PERFORMED:
  • Python: black, isort, flake8, mypy
  • JavaScript: prettier, eslint
  • Rust: rustfmt, clippy
  • All: gitleaks (secrets detection) EXAMPLES:

Install as hook

cp scripts/pre-commit-hook.sh .git/hooks/pre-commit chmod +x .git/hooks/pre-commit

Run directly

./scripts/pre-commit-hook.sh

Skip tests for quick commit

./scripts/pre-commit-hook.sh --skip-tests BYPASS: git commit --no-verify # Skip all hooks SEE ALSO:

  • .pre-commit-config.yaml
  • scripts/lint-all.sh

File: pre-commit-hook.sh

Type: Shell Script

Usage

bash pre-commit-hook.sh
# or
./pre-commit-hook.sh