hk 2.12.0 lets the check_conventional_commit builtin restrict which scopes a commit can use. It also fixes three bugs: misleading errors when a run is stopped by SIGTERM or SIGHUP, missing hooks after hk install --legacy on top of a global install, and stash restore failures caused by another linked worktree.
Added
-
Allowed scopes for conventional commits (#1817, @jonahsnider). Set
allowed_scopesoncheck_conventional_committo limit which scopes commit messages can use:["conventional-commit"] = (Builtins.check_conventional_commit) { allowed_scopes = List("web", "api") }
Commits without a scope are always accepted. A commit with any other scope is rejected, and the error lists the allowed scopes. If you omit
allowed_scopes, any scope is accepted. To accept only commits without a scope, setallowed_scopes = List(). Each list entry must hold one scope, with no commas. The same option is available directly ashk util check-conventional-commit --allowed-scopes web,api.
Fixed
- Clearer message when a run is stopped by SIGTERM or SIGHUP (#1814, @jdx). When an external signal stopped hk, such as a job supervisor's deadline, the hook error named whichever step was running with "command was cancelled". That made the step look like it had failed. hk now names the signal instead, for example
stopped by SIGTERM before the run finished (no step failed); exit 143. Exit codes are unchanged (143 for SIGTERM, 129 for SIGHUP). Ctrl-C output and real step failures are also unchanged. hk install --legacyafter a global install (#1828, @jdx). Ifhk install --globalhad already writtenhook.hk-*entries,hk install --legacyprinted "skipping local install" and wrote nothing. Git versions older than 2.54 don't read config-based hooks, so commits there ran with no hook and no error. With--legacy, hk now installs the.git/hooks/shims even when a global install exists. Plainhk installdoes the same when thegitonPATHis older than 2.54. On git 2.54+, having both global hooks and shims makes hk run twice per event. Without--legacy, git 2.54+ still skips the local install, and--force-localstill overrides the skip.- Stash restore across linked worktrees (#1827, @jdx). With
stash = "git", a commit could fail at the restore step withbad revision 'refs/stash'andfailed to restore stash. This happened when another linked worktree emptied the shared stash stack while the hook ran. No work was lost, but unstaged and untracked changes stayed stashed until you recovered them by hand. hk now looks up its entry on its private refrefs/hk/stash/<commit>first, so races on the shared stack no longer affect those entries. Entries that older hk versions pushed to the shared stack can still hit the race.
New Contributors
- @jonahsnider made their first contribution in #1817
Full Changelog: v2.11.1...v2.12.0
💚 Sponsor hk
hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.
If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.