Skip to content

Comments

feat: hook stage#448

Merged
jdx merged 1 commit intojdx:mainfrom
thejcannon:jcannon/hook-stage
Nov 21, 2025
Merged

feat: hook stage#448
jdx merged 1 commit intojdx:mainfrom
thejcannon:jcannon/hook-stage

Conversation

@thejcannon
Copy link
Contributor

@thejcannon thejcannon commented Nov 20, 2025

Add the ability for configuring stage per-hook.

The impetus here is to move towards a world where hk fix doesn't stage (unless explicitly told to) (see #387 or this discord message).

This is also strengthened by the fact that the docs (until this change) said that stage only applied to pre-commit hooks.


❓ What to do with the fix hook default? I see 3 options:

  1. Make a breaking change to make the default value for hook stage be hook.name == "pre-commit"
  2. Do option 1, but in v2. (If folks are worried about changing semantics, they can set stage themselves in their hook configs. Then changing the default doesn't matter.)
  3. Do nothing. Leave it as is.

❗ NOTE: Unfortunately, since we can't tell if the stage setting came from the .pkl, that means setting stage in the pkl will override stage at the hook level (see test). I think this is desirable for user config but a little wacky for checked-in config. Oh well - its documented, let's move on!


Note

Introduce per-hook stage configuration, update precedence resolution (CLI/env/Pkl > hook, default true), and document/test the behavior.

  • Core/Runtime:
    • Add Hook.stage and update should_stage resolution to: opts.should_stage() -> settings.stage -> hook.stage -> default(true) in src/hook.rs.
  • Config/Schema:
    • Extend pkl/Config.pkl with hooks.<HOOK>.stage: Boolean? and root stage: Boolean?.
    • Update settings.toml for stage (no default; documents that it overrides the hook’s stage).
  • Docs:
    • Add hooks.<HOOK>.stage section and adjust stage setting docs to clarify override precedence.
  • Tests:
    • Add test/stage_setting.bats covering defaults and precedence across hook config, project/user config, git config, env, and CLI.

Written by Cursor Bugbot for commit 44923d3. This will update automatically on new commits. Configure here.

@thejcannon thejcannon marked this pull request as ready for review November 20, 2025 18:20
@jdx
Copy link
Owner

jdx commented Nov 21, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


@jdx jdx merged commit 244cbf0 into jdx:main Nov 21, 2025
17 checks passed
@jdx jdx mentioned this pull request Nov 21, 2025
jdx added a commit that referenced this pull request Nov 21, 2025
## [1.24.0](https://github.com/jdx/hk/compare/v1.23.0..v1.24.0) -
2025-11-21

### 🚀 Features

- hook stage by [@thejcannon](https://github.com/thejcannon) in
[#448](#448)

### 🐛 Bug Fixes

- Pass/render `stdin` for `hk test` tests by
[@thejcannon](https://github.com/thejcannon) in
[#455](#455)

### 📚 Documentation

- Fix `from_ref` docstring by
[@thejcannon](https://github.com/thejcannon) in
[#454](#454)

### ⚡ Performance

- skip stash operations when no unstaged changes by
[@jdx](https://github.com/jdx) in
[#457](#457)
- skip staging when jobs are skipped by conditions by
[@jdx](https://github.com/jdx) in
[#458](#458)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Bump to 1.24.0 with widespread docs/templates updates, corrected CLI
help text, and a small dependency update.
> 
> - **Version bump and release notes**
> - Update crate/app version to `1.24.0` in `Cargo.toml`, `Cargo.lock`,
`hk.usage.kdl`, `docs/cli/commands.json` and docs.
>   - Add `1.24.0` entry to `CHANGELOG.md`.
> - **Docs and templates**
> - Replace package URLs and examples from `v1.23.0` to `v1.24.0` across
docs and example `*.pkl` files.
>   - Update `src/cli/init.rs` template to reference `v1.24.0`.
>   - Adjust version display in CLI docs (`docs/cli/index.md`).
> - **CLI help text fixes**
> - Clarify `--from-ref` help and simplify `--no-fail-fast` descriptions
in `docs/cli/*`, `docs/cli/commands.json`, and `hk.usage.kdl`.
> - **Config error message**
> - Update example `amends` URI in `src/config.rs` error guidance to
`v1.24.0`.
> - **Dependencies**
>   - Bump `pest`/`pest_*` crates to `2.8.4` in `Cargo.lock`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
44258ad. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: mise-en-dev <[email protected]>
@thejcannon thejcannon deleted the jcannon/hook-stage branch November 21, 2025 23:14
@thejcannon
Copy link
Contributor Author

@jdx thoughts on whether hk fix should stage by default?

@jdx
Copy link
Owner

jdx commented Nov 21, 2025

I think nothing right now. I'm considering a v2 where the config might be quite a bit different when this would be a good time for.

@thejcannon
Copy link
Contributor Author

Works for me! 🫡

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 27, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [hk](https://github.com/jdx/hk) | minor | `1.22.0` -> `1.25.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.25.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1250---2025-11-25)

[Compare Source](jdx/hk@v1.24.1...v1.25.0)

##### 🚀 Features

- add fix\_smart\_quotes builtin by [@&#8203;joonas](https://github.com/joonas) in [#&#8203;463](jdx/hk#463)

##### 🐛 Bug Fixes

- Use `stage = "<JOB_FILES>"` for the builtins by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;465](jdx/hk#465)
- Actually makes `files` for step tests default to write keys by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;464](jdx/hk#464)
- remove test cleanup to prevent race conditions by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;468](jdx/hk#468)

### [`v1.24.1`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1241---2025-11-22)

[Compare Source](jdx/hk@v1.24.0...v1.24.1)

##### ⚡ Performance

- show progress bars before expensive git status call by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;459](jdx/hk#459)

### [`v1.24.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1240---2025-11-21)

[Compare Source](jdx/hk@v1.23.0...v1.24.0)

##### 🚀 Features

- hook stage by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;448](jdx/hk#448)

##### 🐛 Bug Fixes

- Pass/render `stdin` for `hk test` tests by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;455](jdx/hk#455)

##### 📚 Documentation

- Fix `from_ref` docstring by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;454](jdx/hk#454)

##### ⚡ Performance

- skip stash operations when no unstaged changes by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;457](jdx/hk#457)
- skip staging when jobs are skipped by conditions by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;458](jdx/hk#458)

### [`v1.23.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1230---2025-11-21)

[Compare Source](jdx/hk@v1.22.0...v1.23.0)

##### 🚀 Features

- **(vacuum)** new builtin by [@&#8203;scop](https://github.com/scop) in [#&#8203;414](jdx/hk#414)
- add --stats flag to show file counts per step by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;446](jdx/hk#446)
- Plumb `stage` through CLI and PKL by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;442](jdx/hk#442)

##### 🐛 Bug Fixes

- **(cli)** check help description by [@&#8203;scop](https://github.com/scop) in [#&#8203;439](jdx/hk#439)

##### 📚 Documentation

- **(stash)** rephrase uncommitted -> unstaged by [@&#8203;scop](https://github.com/scop) in [#&#8203;451](jdx/hk#451)
- re-Remove "auto" stash value by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;444](jdx/hk#444)
- Delete `schema.md` by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;445](jdx/hk#445)
- fix --fix description by [@&#8203;scop](https://github.com/scop) in [#&#8203;450](jdx/hk#450)

##### 📦️ Dependency Updates

- update actions/checkout digest to [`93cb6ef`](jdx/hk@93cb6ef) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;452](jdx/hk#452)
- update anthropics/claude-code-action digest to [`6902c22`](jdx/hk@6902c22) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;453](jdx/hk#453)

</details>

---

### Configuration

📅 **Schedule**: 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:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS4wIiwidXBkYXRlZEluVmVyIjoiNDIuMTkuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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.

2 participants