Skip to content

feat(init): detect Husky / pre-commit / core.hooksPath instead of installing a dead hook#79

Merged
DataDave-Dev merged 1 commit into
mainfrom
feat/init-hook-managers
Jul 3, 2026
Merged

feat(init): detect Husky / pre-commit / core.hooksPath instead of installing a dead hook#79
DataDave-Dev merged 1 commit into
mainfrom
feat/init-hook-managers

Conversation

@DataDave-Dev

Copy link
Copy Markdown
Owner

What

Stacked on #78 (reuses its git.py helpers). Merge #78 first; this PR targets that branch and can be retargeted to main after.

The silent failure this kills: Husky sets core.hooksPath, so git ignores .git/hooks entirely. Before this change, becwright init on a Husky repo wrote a hook there anyway — it looks installed and enforces nothing. The same applies to any custom core.hooksPath.

  • init: when a hook manager owns the hooks (.husky/, .pre-commit-config.yaml, or any core.hooksPath override), skip the native hook and print the exact integration instead — the npx becwright check line for .husky/pre-commit, or the pinned .pre-commit-config.yaml block. Rules are still scaffolded as always.
  • install: refuses with exit 2 under a core.hooksPath override (the hook could never run — refusing beats half-installing). With a pre-commit config but no override, it proceeds as explicitly asked, with a note about the double owner.

Stability

Additive/behavioral fix only. On a plain repo nothing changes; on a manager-owned repo the previous behavior (a dead hook) was a bug, not a contract.

Test plan

  • 7 new tests in tests/test_hook_managers.py: init on plain / Husky / pre-commit / hooksPath repos; install refuses under override, proceeds-with-note under pre-commit config, stays quiet on plain repos
  • Full suite green (280 passed), dogfood hook passed

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@DataDave-Dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bdf64d6e-6ec9-47f7-84a5-16a41ed90fcf

📥 Commits

Reviewing files that changed from the base of the PR and between 0793791 and a258010.

📒 Files selected for processing (6)
  • README.es.md
  • README.md
  • documentation/usage.es.md
  • documentation/usage.md
  • src/becwright/cli.py
  • tests/test_hook_managers.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/init-hook-managers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from feat/doctor-validate to main July 3, 2026 02:10
…talling a dead hook

Husky sets core.hooksPath, so a becwright hook written to .git/hooks is dead
on arrival — git never runs it. Before this change `becwright init` on a
Husky or pre-commit repo silently produced exactly that: a hook that looks
installed and enforces nothing.

- `init`: when a hook manager owns the hooks (Husky dir, pre-commit config,
  or any core.hooksPath override), skip the native hook and print the exact
  integration to add instead (the .husky/pre-commit line, or the
  .pre-commit-config.yaml block pinned to this version). Rules are still
  scaffolded as always.
- `install`: refuses (exit 2) under a core.hooksPath override — the hook
  could never run; with a pre-commit config but no override it proceeds as
  asked, with a note about the double owner.
- Builds on the hook_manager / hooks_path_override helpers from the doctor PR.
- 7 new tests; README(+es) and usage(+es) updated.
@DataDave-Dev DataDave-Dev force-pushed the feat/init-hook-managers branch from 14233a7 to a258010 Compare July 3, 2026 02:13
@DataDave-Dev DataDave-Dev merged commit 6b85e60 into main Jul 3, 2026
5 checks passed
@DataDave-Dev DataDave-Dev deleted the feat/init-hook-managers branch July 3, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant