-
Notifications
You must be signed in to change notification settings - Fork 9
git hooks
Azizul Hakim edited this page Aug 16, 2025
·
1 revision
This project includes Git hooks to ensure code quality and prevent broken code from being committed or pushed.
make setup-hooksmake setup-hooks-winRuns on every git commit and checks:
- β Code formatting (gofmt)
- β Syntax validation
- β Go vet analysis
- β‘ Only checks staged files (fast)
Runs on every git push and performs:
- β
Full test suite (
make test) - β
Linting (
make lint) - if golangci-lint is installed - β Code formatting check
- β Go vet analysis
- π Comprehensive checks (slower but thorough)
- Go (already installed)
- Git (already installed)
Install golangci-lint for comprehensive linting:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestSometimes you need to bypass hooks (use sparingly):
# Skip pre-commit hook
git commit --no-verify -m "commit message"
# Skip pre-push hook
git push --no-verifyIf the automatic setup doesn't work:
# Make hooks executable
chmod +x .githooks/pre-commit
chmod +x .githooks/pre-push
# Copy to .git/hooks
cp .githooks/pre-commit .git/hooks/pre-commit
cp .githooks/pre-push .git/hooks/pre-push
# Or configure Git to use .githooks directory
git config core.hooksPath .githooks# Copy hooks
copy .githooks\pre-commit .git\hooks\pre-commit
copy .githooks\pre-push .git\hooks\pre-push
# Or configure Git to use .githooks directory
git config core.hooksPath .githooks- Check if hooks are executable:
ls -la .git/hooks/ - Verify Git hooks path:
git config core.hooksPath
- Install it:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - Or the hook will skip linting with a warning
- Run
make testmanually to see detailed output - Fix failing tests before committing/pushing
- Run
make formatto auto-fix formatting - Or use
gofmt -w .directly
The hooks are located in .githooks/ directory:
-
.githooks/pre-commit- Pre-commit hook script -
.githooks/pre-push- Pre-push hook script
You can modify these scripts to customize the checks according to your team's needs.
β Prevent broken builds - Catch issues before they reach CI/CD β Consistent code style - Enforce formatting standards β Early bug detection - Find issues during development β Team productivity - Reduce time spent on code review β CI/CD efficiency - Fewer failed builds in CI
- Home - IMS PocketBase BaaS Starter Documentation
- Project Structure - Project organization and architecture
- Environment Configuration - Configuration setup
- Makefile Commands - Development commands
- Database Migrations - Schema management
- Database Seeders - CLI database seeder for dev
- Custom Routes - API endpoints and handlers
- Event Hooks System - PocketBase event handling
- Custom Middleware - Authentication and middleware
- Cron Jobs & Job Queue - Background task processing
- Custom Email System - Email templates and sending
- CLI commands - Command-line interface support for custom scripts and tasks
- Caching System - TTL caching implementation
- Metrics Collection - Application metrics and monitoring
- Centralized Logger - Logging system and configuration
- API Documentation - API documentation generation
- Local Metrics Setup - Development monitoring setup
- Git Hooks Setup - Code quality automation
- Dependency Injection - DI patterns and architecture