📝 docs: add ADR for staged-only Git hooks formatting
- Add ADR-0012 documenting the decision to format only staged Go files - Update ADR README.md with new entry - Document rationale, alternatives, and verification results - Include future considerations for monitoring and CI/CD integration Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
67
.vibe/skills/commit_message/assets/git-hooks/README.md
Normal file
67
.vibe/skills/commit_message/assets/git-hooks/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Git Hooks for DanceLessonsCoach
|
||||
|
||||
This directory contains Git hooks for the DanceLessonsCoach project.
|
||||
|
||||
## Available Hooks
|
||||
|
||||
### pre-commit
|
||||
- **Location**: `.git/hooks/pre-commit`
|
||||
- **Purpose**: Automatically runs `go mod tidy` and `go fmt` before commits
|
||||
- **Features**:
|
||||
- Runs `go mod tidy` to clean up dependencies
|
||||
- Automatically adds modified `go.mod` and `go.sum` to commit
|
||||
- Runs `go fmt` on 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`)
|
||||
|
||||
## Installation
|
||||
|
||||
The pre-commit hook is already installed and executable. No additional setup required.
|
||||
|
||||
## Usage
|
||||
|
||||
The hooks run automatically when you commit:
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "✨ feat: add new feature"
|
||||
```
|
||||
|
||||
The hook will:
|
||||
1. Run `go mod tidy`
|
||||
2. Run `go fmt` on all Go files
|
||||
3. Add any modified files to your commit
|
||||
4. Allow the commit to proceed if successful
|
||||
|
||||
## Customization
|
||||
|
||||
To modify the hooks:
|
||||
1. Edit the hook file in `.git/hooks/`
|
||||
2. Make it executable: `chmod +x .git/hooks/hook-name`
|
||||
|
||||
## Disabling Hooks
|
||||
|
||||
To temporarily disable hooks:
|
||||
|
||||
```bash
|
||||
# Skip pre-commit hook for one commit
|
||||
git commit --no-verify -m "✨ feat: add new feature"
|
||||
```
|
||||
|
||||
## 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 tidy` fails: Check your Go module dependencies
|
||||
- `go fmt` fails: Check for syntax errors in your Go code
|
||||
43
.vibe/skills/commit_message/assets/git-hooks/pre-commit
Executable file
43
.vibe/skills/commit_message/assets/git-hooks/pre-commit
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
# DanceLessonsCoach pre-commit hook
|
||||
# Runs go mod tidy and go fmt before allowing commits
|
||||
|
||||
echo "Running pre-commit hooks..."
|
||||
|
||||
# Check if we're in a Go project
|
||||
if [ ! -f "go.mod" ]; then
|
||||
echo "Not a Go project, skipping hooks"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run go mod tidy
|
||||
echo "Running go mod tidy..."
|
||||
go mod tidy
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: go mod tidy failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if go.mod or go.sum were modified
|
||||
if git diff --cached --name-only | grep -qE '(go\.mod|go\.sum)'; then
|
||||
echo "go.mod or go.sum changed, adding to commit..."
|
||||
git add go.mod go.sum
|
||||
fi
|
||||
|
||||
# Run go fmt on all Go files
|
||||
echo "Running go fmt..."
|
||||
GOFILES=$(find . -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
|
||||
if [ -n "$GOFILES" ]; then
|
||||
gofmt -w $GOFILES
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: go fmt failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add formatted files to commit
|
||||
git add $GOFILES
|
||||
fi
|
||||
|
||||
echo "Pre-commit hooks completed successfully"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user