feat: add HK_STAGE setting to control automatic staging of fixed files#313
Merged
feat: add HK_STAGE setting to control automatic staging of fixed files#313
Conversation
- Add new 'stage' setting with default value true - When HK_STAGE=0, fixed files remain unstaged for manual review - Addresses user request for v1 PRESERVE_HUNKS=1 behavior - Includes comprehensive bats tests for the new setting
| ctx.hook_ctx.git.lock().await.add(&filtered)?; | ||
| if Settings::get().stage { | ||
| ctx.hook_ctx.git.lock().await.add(&filtered)?; | ||
| } |
There was a problem hiding this comment.
Bug: Git Staging Inconsistency
When Settings::get().stage is false, files are not staged in Git. However, the classification logic and ctx.add_files() still execute, causing hk to track files as staged (added/created) even though they weren't actually added to the Git index. This creates an inconsistent internal state.
Merged
jdx
added a commit
that referenced
this pull request
Oct 2, 2025
## [1.16.0](https://github.com/jdx/hk/compare/v1.15.7..v1.16.0) - 2025-10-02 ### 🚀 Features - add HK_STAGE setting to control automatic staging of fixed files by [@jdx](https://github.com/jdx) in [#313](#313) - suppress check output_summary when fixer runs with check_first by [@jdx](https://github.com/jdx) in [#315](#315) ### 🐛 Bug Fixes - --slow flag now properly enables slow profile by [@jdx](https://github.com/jdx) in [#317](#317) ### 📚 Documentation - Update getting_started.md by [@jdx](https://github.com/jdx) in [a8c1a35](a8c1a35) ### 🔍 Other Changes - Update getting_started.md by [@jdx](https://github.com/jdx) in [58c0564](58c0564) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Release v1.16.0 with new staging control, output suppression tweak, a --slow flag fix, docs update, and version/dependency bumps. > > - **Release `1.16.0`** > - **Features**: add `HK_STAGE` setting; suppress `check` output_summary when fixer runs with `check_first`. > - **Bug Fix**: `--slow` flag now enables the `slow` profile. > - **Docs**: update `getting_started.md`. > - **Versioning**: bump crate to `1.16.0` in `Cargo.toml`; update CLI version in `docs/cli/commands.json`, `docs/cli/index.md`, and `hk.usage.kdl`. > - **Dependencies**: update crates in `Cargo.lock` (e.g., `anstyle`, `deflate64`, `owo-colors`, `quote`, `rustls-webpki`, `typenum`, `usage-lib`, `zeroize`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bffe2fc. 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]>
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Oct 10, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [hk](https://github.com/jdx/hk) | minor | `1.15.7` -> `1.18.3` | 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.18.3`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1183---2025-10-07) [Compare Source](jdx/hk@v1.18.2...v1.18.3) ##### 🐛 Bug Fixes - stash untracked files during partial stashes when HK\_STASH\_UNTRACKED=true by [@​jdx](https://github.com/jdx) in [#​357](jdx/hk#357) ### [`v1.18.2`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1182---2025-10-06) [Compare Source](jdx/hk@v1.18.1...v1.18.2) ##### 🐛 Bug Fixes - stage directive to include untracked files matching globs by [@​jdx](https://github.com/jdx) in [#​355](jdx/hk#355) ### [`v1.18.1`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1181---2025-10-05) [Compare Source](jdx/hk@v1.18.0...v1.18.1) ##### 🐛 Bug Fixes - prevent race condition when files are deleted between collection and execution by [@​jdx](https://github.com/jdx) in [#​353](jdx/hk#353) ### [`v1.18.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1180---2025-10-05) [Compare Source](jdx/hk@v1.16.0...v1.18.0) ##### 🚀 Features - add fix-smart-quotes util by [@​joonas](https://github.com/joonas) in [#​348](jdx/hk#348) ##### 🐛 Bug Fixes - add Windows support by guarding Unix-specific file permission APIs by [@​jdx](https://github.com/jdx) in [#​349](jdx/hk#349) - handle missing files in update-version script by [@​jdx](https://github.com/jdx) in [#​350](jdx/hk#350) - rewrite update-version script to avoid pipefail issues by [@​jdx](https://github.com/jdx) in [211b1ac](jdx/hk@211b1ac) - run render before update-version in release script by [@​jdx](https://github.com/jdx) in [35d2df3](jdx/hk@35d2df3) - use \[0-9] instead of \d in ripgrep pattern for better compatibility by [@​jdx](https://github.com/jdx) in [cf8ebb0](jdx/hk@cf8ebb0) - explicitly specify search path for ripgrep in update-version script by [@​jdx](https://github.com/jdx) in [5666f96](jdx/hk@5666f96) ##### 🔍 Other Changes - add diagnostic output to update-version script by [@​jdx](https://github.com/jdx) in [aaeea63](jdx/hk@aaeea63) - add more file existence checks by [@​jdx](https://github.com/jdx) in [cbace40](jdx/hk@cbace40) - test rg pattern matching in CI environment by [@​jdx](https://github.com/jdx) in [a52ea46](jdx/hk@a52ea46) ##### New Contributors - [@​joonas](https://github.com/joonas) made their first contribution in [#​348](jdx/hk#348) ### [`v1.16.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1160---2025-10-02) [Compare Source](jdx/hk@v1.15.7...v1.16.0) ##### 🚀 Features - add HK\_STAGE setting to control automatic staging of fixed files by [@​jdx](https://github.com/jdx) in [#​313](jdx/hk#313) - suppress check output\_summary when fixer runs with check\_first by [@​jdx](https://github.com/jdx) in [#​315](jdx/hk#315) ##### 🐛 Bug Fixes - \--slow flag now properly enables slow profile by [@​jdx](https://github.com/jdx) in [#​317](jdx/hk#317) ##### 📚 Documentation - Update getting\_started.md by [@​jdx](https://github.com/jdx) in [a8c1a35](jdx/hk@a8c1a35) ##### 🔍 Other Changes - Update getting\_started.md by [@​jdx](https://github.com/jdx) in [58c0564](jdx/hk@58c0564) </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:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzIuNSIsInVwZGF0ZWRJblZlciI6IjQxLjEzOC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HK_STAGEsetting to control whether fixed files are automatically stagedHK_STAGE=0is set, files modified by fixers remain unstaged for manual reviewPRESERVE_HUNKS=1behaviorContext
Users previously using v1 with
PRESERVE_HUNKS=1were seeing different behavior in v2 where pre-commit hooks would automatically stage generated file changes. This PR introducesHK_STAGEsetting (default: true) to allow users to opt out of automatic staging.Changes
stagesetting tosettings.tomlwith env varHK_STAGEand git confighk.stagesrc/step.rsto check the setting before staging filestest/stage_setting.batsTest plan
🤖 Generated with Claude Code
Note
Adds a new
stage(HK_STAGE/hk.stage) setting (default: true) to toggle automatic staging of files fixed by hooks, updates staging behavior accordingly, and documents/tests it.stagesetting (bool, defaulttrue) with sourcesHK_STAGEandhk.stageinsettings.tomlanddocs/configuration.md.src/step.rs, only stage matched files whenSettings::get().stageis enabled; otherwise skip adding to index.test/stage_setting.batscoveringHK_STAGE=0, default behavior, andgit config hk.stage=false.Written by Cursor Bugbot for commit 33ad9fd. This will update automatically on new commits. Configure here.