Skip to content

Latest commit

 

History

History
114 lines (89 loc) · 3.32 KB

File metadata and controls

114 lines (89 loc) · 3.32 KB

Complete Git Hooks Summary

Overview

All 5 git hooks now installed and active via lefthook: ✓ pre-commit ✓ commit-msg
✓ pre-push ✓ post-checkout ✓ post-merge

Hook Details

1. Pre-Commit (~4-6s)

Purpose: Quality gates to ensure code meets standards before commit

Runs in parallel:

  • go mod tidy validation
  • go vet static analysis
  • gofmt formatting check
  • golangci-lint comprehensive linting
  • golangci-lint extra quality linters
  • gosec security scanning
  • Secret detection (checks code files only)

When it runs: Every commit Can skip: No (quality enforcement)

2. Commit-Msg (~0.01s)

Purpose: Enforce commit message standards

Validates:

  • Minimum 10 character length
  • Conventional commits format (recommends, doesn't enforce)
    • Format: type(scope): message
    • Types: feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert
  • Blocks WIP commits to main/master branches
  • Allows merge commits

Examples: ✓ "feat(core): add new scheduler algorithm" ✓ "fix(web): resolve authentication timeout issue" ✗ "test" (too short) ✗ "WIP commit" (on main branch)

When it runs: Every commit (after pre-commit) Can skip: No (message quality)

3. Pre-Push (~10-30s)

Purpose: Final safety check before code reaches remote

Checks:

  • Full test suite with race detection (go test -race -timeout=5m ./...)
  • Protected branch warnings (main/master/production)
    • Interactive prompt: requires "yes" to proceed
  • Quick lint check on changed files

When it runs: Every git push Can skip: Yes (ctrl+c on protected branch prompt)

4. Post-Checkout (~instant)

Purpose: Developer reminders after switching branches

Checks:

  • Dependency changes (go.mod/go.sum)
    • Reminds to run: go mod download
  • Hook installation status
    • Reminds to run: make setup (if hooks not installed)

When it runs: After git checkout Can skip: N/A (informational only)

5. Post-Merge (~2-5s if dependencies changed)

Purpose: Auto-update dependencies after merging

Actions:

  • Detects go.mod/go.sum changes in merge
  • Automatically runs: go mod download
  • Suggests running tests after update

When it runs: After git merge Can skip: N/A (automatic, helpful)

Performance Summary

Hook Typical Time Max Time Skippable
pre-commit 4-6s 10s No
commit-msg <0.1s <0.1s No
pre-push 10-30s 60s+ Yes*
post-checkout <0.1s <0.1s Info only
post-merge 0-5s 10s Auto

*Protected branch prompt only

Benefits

  1. Quality Enforcement: All commits meet code standards
  2. Message Standards: Consistent commit history for changelogs
  3. Test Safety: Broken code never reaches remote
  4. Protected Branches: Prevents accidental pushes to main
  5. Dependency Management: Auto-updates after merges
  6. Developer Experience: Fast parallel execution

Comparison to Previous Setup

Aspect Before (Husky) After (lefthook)
Hooks pre-commit only All 5 hooks
Speed ~6-9s ~4-6s
Dependencies Node.js None (Go)
Test Suite Manual Automatic (pre-push)
Message Validation None Conventional commits
Protected Branches None Warning system
Dependency Updates Manual Automatic