Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/usr/bin/env sh
# Fallow gate: block commits that introduce new complexity or duplication
# beyond the frozen baselines in .fallow/. Matches CI's --base argument
# exactly (origin/main) so audit scopes to the same diff here and in
# CI; auto-detection can pick a different ref when origin/main is
# stale or when multiple remotes are configured, giving false-green
# locally. If origin/main is behind, run `git fetch origin main` first.
# To lower a baseline, refactor the flagged code and regenerate:
# beyond the frozen baselines in .fallow/. Mirrors CI's --base selection
# by following origin/HEAD (the repo's actual default branch), so the
# hook adapts if the default changes and doesn't silently diverge from
# the CI step's `github.base_ref || default_branch` fallback.
# Non-default-target PRs (e.g. a branch targeting staging while origin
# defaults to main) will diff differently here than CI will — that's
# inherent to pre-commit since the eventual PR target isn't known yet.
# If origin/<default> is behind, run `git fetch` first. To lower a
# baseline, refactor the flagged code and regenerate:
# npx fallow health --save-baseline=.fallow/health-baseline.json
# npx fallow dupes --save-baseline=.fallow/dupes-baseline.json
BASE=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null)
BASE=${BASE:-origin/main}
npx fallow audit \
--health-baseline=.fallow/health-baseline.json \
--dupes-baseline=.fallow/dupes-baseline.json \
--base=origin/main
--base="$BASE"
Loading