feat(hook): support per-worktree hooks via extensions.worktreeConfig#789
feat(hook): support per-worktree hooks via extensions.worktreeConfig#789
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for per-worktree git hooks by checking the core.hooksPath configuration via git config --worktree. The install and uninstall commands have been updated to prioritize worktree-local hook directories when configured. Additionally, new integration tests were added to verify this behavior. One review comment suggests improving error handling during path canonicalization in git_util.rs to avoid swallowing potential filesystem errors.
Greptile SummaryThis PR adds per-worktree hook installation support: when Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[hk install / hk uninstall] --> B{worktree_hooks_path}
B --> C{extensions.worktreeConfig == true?}
C -->|No| F[None]
C -->|Yes| D{core.hooksPath set\nin --worktree scope?}
D -->|No| F
D -->|Yes| E[Some: worktree-local path]
E -->|install| G[mkdirp + write hooks\nto worktree path]
E -->|uninstall| H[remove hk hooks\nfrom worktree path]
F -->|install| I[check_hooks_path_config\nglobal + local warning]
I --> J[resolve shared hooks dir\nvia commondir]
J --> K[write hooks to\nshared hooks dir]
F -->|uninstall| L[resolve shared hooks dir\nvia commondir]
L --> M[remove hk hooks\nfrom shared hooks dir]
Reviews (7): Last reviewed commit: "Merge branch 'main' into worktree-worktr..." | Re-trigger Greptile |
20fd751 to
82b5279
Compare
When hk install runs in a git worktree where extensions.worktreeConfig is enabled, hooks are now installed to the worktree-local git dir with core.hooksPath set per-worktree. The full path to hk is embedded in the hook script to avoid PATH issues in non-interactive shells. If extensions.worktreeConfig is not enabled, the existing shared-hooks behavior is preserved. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33c61d7 to
afcce83
Compare
### 🚀 Features - **(hook)** support per-worktree hooks via extensions.worktreeConfig by [@nkakouros](https://github.com/nkakouros) in [#789](#789) ### 🐛 Bug Fixes - **(config)** use XDG_CONFIG_HOME for config path instead of dirs::config_dir() by [@fukuchancat](https://github.com/fukuchancat) in [#801](#801) ### 📦️ Dependency Updates - update anthropics/claude-code-action digest to 0432df8 by [@renovate[bot]](https://github.com/renovate[bot]) in [#791](#791) - update rust crate indexmap to v2.13.1 by [@renovate[bot]](https://github.com/renovate[bot]) in [#792](#792) - update actions/configure-pages action to v6 by [@renovate[bot]](https://github.com/renovate[bot]) in [#795](#795) - update rust crate strum to 0.28 by [@renovate[bot]](https://github.com/renovate[bot]) in [#794](#794) - update actions/deploy-pages action to v5 by [@renovate[bot]](https://github.com/renovate[bot]) in [#796](#796) - update dependency globals to v17 by [@renovate[bot]](https://github.com/renovate[bot]) in [#797](#797) - update github artifact actions (major) by [@renovate[bot]](https://github.com/renovate[bot]) in [#798](#798) - update jdx/mise-action action to v4 by [@renovate[bot]](https://github.com/renovate[bot]) in [#799](#799) ### New Contributors - @fukuchancat made their first contribution in [#801](#801) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Primarily a version bump and documentation/lockfile updates; no functional Rust source changes are included in this diff. > > **Overview** > Publishes the `v1.41.0` release by bumping the crate/CLI version (`Cargo.toml`, `Cargo.lock`, `hk.usage.kdl`, generated CLI docs) and adding the `1.41.0` entry to `CHANGELOG.md`. > > Updates documentation and example Pkl snippets to reference the `v1.41.0` release artifacts, and refreshes `Cargo.lock` with dependency patch/minor updates (e.g., `tokio`, ICU crates, `signal-hook`, `semver`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0c8dea7. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [hk](https://github.com/jdx/hk) | minor | `1.40.0` → `1.41.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jdx/hk (hk)</summary> ### [`v1.41.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1410---2026-04-05) [Compare Source](jdx/hk@v1.40.0...v1.41.0) ##### 🚀 Features - **(hook)** support per-worktree hooks via extensions.worktreeConfig by [@​nkakouros](https://github.com/nkakouros) in [#​789](jdx/hk#789) ##### 🐛 Bug Fixes - **(builtins)** use workspace\_indicator for Go package-level analysis tools by [@​jdx](https://github.com/jdx) in [#​803](jdx/hk#803) - **(config)** use XDG\_CONFIG\_HOME for config path instead of dirs::config\_dir() by [@​fukuchancat](https://github.com/fukuchancat) in [#​801](jdx/hk#801) ##### 📦️ Dependency Updates - update anthropics/claude-code-action digest to [`0432df8`](jdx/hk@0432df8) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​791](jdx/hk#791) - update rust crate indexmap to v2.13.1 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​792](jdx/hk#792) - update actions/configure-pages action to v6 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​795](jdx/hk#795) - update rust crate strum to 0.28 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​794](jdx/hk#794) - update actions/deploy-pages action to v5 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​796](jdx/hk#796) - update dependency globals to v17 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​797](jdx/hk#797) - update github artifact actions (major) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​798](jdx/hk#798) - update jdx/mise-action action to v4 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​799](jdx/hk#799) ##### New Contributors - [@​fukuchancat](https://github.com/fukuchancat) made their first contribution in [#​801](jdx/hk#801) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDQuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwNC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Summary
When
extensions.worktreeConfigis enabled and a per-worktreecore.hooksPathis set,hk installandhk uninstallnow respect that path instead of always using the shared$GIT_COMMON_DIR/hooks/directory.This allows different worktrees to have independent hook configurations without conflicting with each other.
Users set up
extensions.worktreeConfigandcore.hooksPaththemselves. hk just reads and respects what's there.Setup example