diff --git a/.vibe/skills/commit_message/SKILL.md b/.vibe/skills/commit_message/SKILL.md index 2c8df99..73a9ae8 100644 --- a/.vibe/skills/commit_message/SKILL.md +++ b/.vibe/skills/commit_message/SKILL.md @@ -88,7 +88,7 @@ The project includes Git hooks that automatically run before commits to ensure c - **Location**: `.git/hooks/pre-commit` - **Automatically runs**: - `go mod tidy` - Cleans up and organizes Go dependencies - - `go fmt` - Formats all Go code according to standards + - `go fmt` - Formats staged Go files according to standards - Auto-adds modified files to the commit ### How It Works diff --git a/.vibe/skills/commit_message/assets/git-hooks/README.md b/.vibe/skills/commit_message/assets/git-hooks/README.md index dcb9027..680ccea 100644 --- a/.vibe/skills/commit_message/assets/git-hooks/README.md +++ b/.vibe/skills/commit_message/assets/git-hooks/README.md @@ -10,7 +10,7 @@ This directory contains Git hooks for the DanceLessonsCoach project. - **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) + - Runs `go fmt` on staged Go files only - Automatically adds formatted files to commit - Only runs if in a Go project (checks for `go.mod`) diff --git a/.vibe/skills/commit_message/assets/git-hooks/pre-commit b/.vibe/skills/commit_message/assets/git-hooks/pre-commit index f9739fb..ca1f651 100755 --- a/.vibe/skills/commit_message/assets/git-hooks/pre-commit +++ b/.vibe/skills/commit_message/assets/git-hooks/pre-commit @@ -25,18 +25,18 @@ if git diff --cached --name-only | grep -qE '(go\.mod|go\.sum)'; then 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 +# Run go fmt on staged Go files only +echo "Running go fmt on staged files..." +STAGED_GOFILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') +if [ -n "$STAGED_GOFILES" ]; then + gofmt -w $STAGED_GOFILES if [ $? -ne 0 ]; then echo "ERROR: go fmt failed" exit 1 fi # Add formatted files to commit - git add $GOFILES + git add $STAGED_GOFILES fi echo "Pre-commit hooks completed successfully"