diff --git a/.gitignore b/.gitignore index 6e43ac78..7ccb7d6f 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,5 @@ electron/out/ android/.gradle/file-system.probe android/.gradle/caches/ -coverage/ \ No newline at end of file +coverage/ +.husky-enabled diff --git a/.husky/README.md b/.husky/README.md new file mode 100644 index 00000000..2f887b08 --- /dev/null +++ b/.husky/README.md @@ -0,0 +1,37 @@ +# Husky Git Hooks - Optional Activation + +## How to Enable Husky Locally + +### Option 1: Environment Variable (Session Only) +```bash +export HUSKY_ENABLED=1 +``` + +### Option 2: Local File (Persistent) +```bash +touch .husky-enabled +``` + +### Option 3: Global Configuration +```bash +git config --global husky.enabled true +``` + +## Available Hooks + +- **pre-commit**: Runs `npm run lint-fix` before commits +- **commit-msg**: Validates commit message format + +## Disable Hooks + +```bash +unset HUSKY_ENABLED +rm .husky-enabled +``` + +## Why This Approach? + +- Hooks are committed to git for consistency +- Hooks don't run unless explicitly enabled +- Each developer can choose to use them +- No automatic activation on other systems diff --git a/.husky/commit-msg b/.husky/commit-msg index 4b8c242d..d56e599e 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -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 diff --git a/.husky/pre-commit b/.husky/pre-commit index 7d7b33e3..753370e7 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,15 +1,11 @@ -#!/usr/bin/env bash -# -# Husky Pre-commit Hook -# Runs Build Architecture Guard to check staged files -# +#!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -echo "🔍 Running Build Architecture Guard (pre-commit)..." -bash ./scripts/build-arch-guard.sh --staged || { - echo - echo "💡 To bypass this check for emergency commits, use:" - echo " git commit --no-verify" - echo - exit 1 -} +# Only run if Husky is enabled +if [ "$HUSKY_ENABLED" = "1" ] || [ -f .husky-enabled ]; then + echo "Running pre-commit hooks..." + npm run lint-fix +else + echo "Husky pre-commit hook skipped (not enabled)" + exit 0 +fi