hk migrate pre-commit
- How to hail it:
hk migrate pre-commit [FLAGS] - Effect: modifies state (it touches, as well as looks)
Change ships: migrate from pre-commit (or prek) to hk.
It reads a .pre-commit-config.yaml and writes an hk.pkl (the ship's charts) that runs the same hooks at the same git stages:
- Hooks from well-known repositories join the standing crew as hk builtins. For example,
rufffrom astral-sh/ruff-pre-commit becomesBuiltins.ruff. - Local
system,script, andfailhooks sign on as native hk steps, with the same command and file filters. - Every other hook keeps sailing under prek or pre-commit, which reads the original config. That includes hooks whose
args,additional_dependencies, or filters a builtin cannot reproduce. Each of these steps carries a comment saying why it was not converted.
manual hooks run only with hk check and hk fix; no other call musters them.
Flags to fly
-c --config <CONFIG>— Path to the .pre-commit-config.yaml to readUnless ye say otherwise:
.pre-commit-config.yaml-f --force— Overwrite an existing hk.pkl file; the old charts are written over-o --output <OUTPUT>— Output path for the hk.pkl, where the new charts are writtenUnless ye say otherwise:
hk.pkl--runner <RUNNER>— The tool that runs the hooks hk cannot convert. It defaults to pre-commit when only pre-commit is on PATH, and to prek otherwise.Choose from:
prek,pre-commit--hk-pkl-root <HK_PKL_ROOT>— Root path for hk's pkl files (e.g. "pkl" for a local checkout, or a package URL prefix). If it's set, the generated config uses {root}/Config.pkl and {root}/Builtins.pkl-h --help— Print help, for when ye've lost yer bearings
Tales from the deck
Write to a separate file while ye weigh up a migration. Steps that still sail under prek or pre-commit are marked with a comment saying why.
hk migrate pre-commit --output hk.migrated.pkl
HK_FILE=./hk.migrated.pkl hk check --all --planFurther charts
Getting started: get under way · Troubleshooting: the ship's log · All the bosun's calls
