| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
cz init already treated prek as installed, but always ran `pre-commit install`, which raised FileNotFoundError when only prek was on PATH. Use the available installer, and ask when both exist. Fixes commitizen-tools#2018
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #2065 +/- ##
=======================================
Coverage 98.24% 98.25%
=======================================
Files 61 61
Lines 2799 2815 +16
=======================================
+ Hits 2750 2766 +16
Misses 49 49 ☔ View full report in Codecov by Harness. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the PR, one comment only
Sorry, something went wrong.
If neither pre-commit nor prek is on PATH, skip the hook-type question instead of failing init. Users who want hooks can install a tool and retry.
The InitFailedError branch in _ask_hook_installer was flagged by codecov as the only uncovered line of the PR. Add a test where the installer is available during the hook-type question but disappears before the install step, so the guard is exercised instead of removed.
|
Addressed in c9ea08e: when neither pre-commit nor prek is on PATH, cz init now skips the hook question entirely and prints No pre-commit hook detected, skipping question, so users who want hooks know to install one and re-run. I also noticed codecov flagged one uncovered line — the InitFailedError branch in _ask_hook_installer(). I kept it as a guard against the installer disappearing between the question and the install step (e.g. PATH change), and added a test for it in bb343bc instead of removing it. Could you take another look when you get a chance? Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
cz init already treated prek as a valid hook installer (is_pre_commit_installed()), but the install step always ran pre-commit install. When only prek is on PATH, that raises FileNotFoundError.
This change:
Fixes #2018
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Cursor Grok following the guidelines
Code Changes
Manual testing: unit tests cover only-prek, only-pre-commit, both (prompt), and neither (InitFailedError). ruff check and mypy pass on the touched files. I did not run the full interactive cz init UI in a throwaway repo.
Documentation Changes
Docs change is a one-line note in docs/commands/init.md. I did not rebuild the full mkdocs site.
Expected Behavior
Steps to Test This Pull Request
Additional Context
Owner-confirmed in #2018 (issue-status: wait-for-implementation). Desired behavior is from the issue: treat the two tools as interchangeable, auto-select when only one is present, ask when both are.