Git Hooks for dance-lessons-coach
This directory contains Git hooks for the dance-lessons-coach project.
Available Hooks
pre-commit
- Location:
.git/hooks/pre-commit - Purpose: Automatically runs
go mod tidyandgo fmtbefore commits - Features:
- Runs
go mod tidyto clean up dependencies - Automatically adds modified
go.modandgo.sumto commit - Runs
go fmton all Go files (excluding vendor and .git directories) - Automatically adds formatted files to commit
- Only runs if in a Go project (checks for
go.mod)
- Runs
Installation
The pre-commit hook is already installed and executable. No additional setup required.
Usage
The hooks run automatically when you commit:
git add .
git commit -m "Your commit message"
The hook will:
- Run
go mod tidy - Run
go fmton all Go files - Add any modified files to your commit
- Allow the commit to proceed if successful
Customization
To modify the hooks:
- Edit the hook file in
.git/hooks/ - Make it executable:
chmod +x .git/hooks/hook-name
Disabling Hooks
To temporarily disable hooks:
# Skip pre-commit hook for one commit
git commit --no-verify -m "Your commit message"
Best Practices
- Let the hooks run automatically - they ensure code quality
- The hooks only modify files that need changes
- All changes are added to your commit automatically
- Hooks run quickly and prevent common issues
Troubleshooting
If a hook fails:
- Check the error message
- Fix the issue manually
- Commit again
Common issues:
go mod tidyfails: Check your Go module dependenciesgo fmtfails: Check for syntax errors in your Go code