feat(git-hooks): implement conditional Husky activation system
- Implements conditional activation logic in husky.sh helper script - Updates pre-commit hook to run linting only when enabled - Updates commit-msg hook to validate messages only when enabled - Adds .husky-enabled to .gitignore for user-specific activation - Creates user activation instructions in .husky/README.md - Provides graceful fallback when hooks are disabled Activation: Environment variable, local file, or global config Hooks: Pre-commit (linting) and commit-msg (validation) Behavior: Optional activation with helpful instructions when disabled
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Husky Commit Message Hook
|
||||
# Validates commit message format using commitlint
|
||||
#
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Run commitlint but don't fail the commit (|| true)
|
||||
# This provides helpful feedback without blocking commits
|
||||
npx commitlint --edit "$1" || true
|
||||
# Only run if Husky is enabled
|
||||
if [ "$HUSKY_ENABLED" = "1" ] || [ -f .husky-enabled ]; then
|
||||
echo "Running commit-msg hooks..."
|
||||
npx commitlint --edit "$1"
|
||||
else
|
||||
echo "Husky commit-msg hook skipped (not enabled)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user