fix: add top-level exclude property to hk.pkl#299
Merged
Conversation
- Add global exclude property to Config.pkl schema - Support List<String> for global file exclusion patterns - Integrate config exclude patterns with existing exclude logic in hook.rs - Add comprehensive bats tests for top-level exclude functionality - Supports both single patterns and multiple patterns - Works in combination with existing step-level exclude patterns - Handles directory patterns (e.g., "node_modules", "dist") 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update Config.pkl schema to accept both String and List<String> for exclude field
- Add serde deserializer to handle String to Vec<String> conversion in Rust
- Add comprehensive tests for both String and List syntax
- Maintain backward compatibility with existing configurations
Examples:
- exclude = "*.test.js" (single string)
- exclude = List("*.test.js", "*.spec.ts") (list of strings)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace custom serde deserializer with existing StringOrList enum - Follow the same pattern used by other config fields in the codebase - Cleaner implementation that leverages existing infrastructure - Removes unnecessary custom deserialization code 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove --exclude-glob from CLI options as --exclude now handles glob patterns - Update settings.toml to remove exclude-glob references - Update test to use --exclude instead of --exclude-glob - Simplify CLI interface by consolidating exclude functionality Since all exclude patterns are treated as globs anyway, having separate --exclude and --exclude-glob options was redundant and confusing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add exclude field to collect_pkl_map() in settings system - Handle StringOrList conversion properly for PKL exclude patterns - Remove redundant manual config loading in hook.rs - Now all PKL config fields are loaded through unified settings system This provides a clean, unified approach where: - Settings system handles all configuration sources (CLI, env, git, PKL) - No duplicate loading or manual config parsing needed - Proper merge semantics with union behavior for list fields - Consistent with other settings fields 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add iter() method to StringOrList enum
- Implement IntoIterator trait for owned iteration
- Refactor all StringOrList match patterns to use v.into_iter().collect()
- Significantly cleaner and more idiomatic Rust code
Before:
```rust
match v {
StringOrList::String(s) => vec![s.clone()],
StringOrList::List(list) => list.clone(),
}
```
After:
```rust
v.into_iter().collect()
```
This makes StringOrList behave like any other iterable collection,
reducing boilerplate and improving code readability.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace manual field enumeration with metadata-driven approach - Use SETTINGS_META to discover which fields have PKL sources - Dynamically extract field values using serde_json conversion - Handle both String and Array serialization of StringOrList types - More maintainable: adding PKL fields only requires updating settings.toml Benefits: - No more manual field additions to collect_pkl_map() - Automatic support for any field with PKL sources - Type-safe based on metadata type information - Handles StringOrList serialization variants correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ttings.rs Previously, config loading errors were silently ignored using `if let Ok(cfg) = ...` patterns. This could hide important configuration issues. Now these functions properly return Result<SourceMap, eyre::Error> and propagate errors to callers with appropriate warnings. Changes: - collect_git_map() now returns Result and propagates git config errors - collect_pkl_map() now returns Result and propagates pkl config errors - build_from_all_sources() updated to handle Result types with fallback warnings - explain_value() updated to handle config errors properly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…sages Previously, get_snapshot() would silently fall back to defaults when config loading failed. Now it properly propagates errors up through the call chain, resulting in clear error messages for users when configuration files are broken. Changes: - get_snapshot() now returns Result<SettingsSnapshot, eyre::Error> - Settings::get() uses expect() to provide clear "Failed to load configuration" message - Config errors now cause immediate failure with helpful error details instead of silent fallback - Removed unused settings! macro This ensures users get proper feedback when their config files have syntax errors or other issues, rather than mysteriously getting default behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added Settings::try_get() as a non-panicking alternative to Settings::get() that returns Result<Settings, eyre::Error> for callers that want to handle config errors gracefully. Updated strategic CLI commands to use try_get(): - config dump/get/explain commands now handle config errors gracefully - test command uses try_get() for parallel job configuration - These commands can now show warnings instead of panicking on config errors Benefits: - Diagnostic commands (config) can function even with broken configs - Better user experience with graceful degradation - Settings::get() kept for backward compatibility where panicking is preferred - Clear separation between "must work" vs "best effort" config access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…tests Performance optimization: - Settings::get() and try_get() now return Arc<Settings> instead of cloning - Eliminates expensive Settings struct cloning on every access - Uses .as_ref() for serialization where needed Testing improvements: - Added comprehensive bats tests for config error handling - Verifies hk check/fix/run fail properly on invalid configs - Tests config commands (get/dump/explain) fail with helpful error messages - Ensures error messages include file paths and syntax details Benefits: - Better performance: no more cloning large Settings structs - Better testing: validates error handling works correctly - Better UX: users get clear feedback on config problems 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…dling Breaking change: - Removed hk.excludeGlob backward compatibility test since we no longer support it - Users should migrate to the new top-level exclude property in hk.pkl Error handling improvements: - collect_env_map() now returns Result and properly reports invalid env var values - Environment variables like HK_JOBS=abc now error instead of being silently ignored - Clear error messages show which env var has invalid value and expected format This ensures users get proper feedback when environment variables have invalid values instead of mysterious fallback to defaults. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add schema documentation for the new exclude field in Config.pkl to fix CI docs-sync check failure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Merged
jdx
added a commit
that referenced
this pull request
Sep 21, 2025
## [1.15.3](https://github.com/jdx/hk/compare/v1.15.2..v1.15.3) - 2025-09-21 ### 🐛 Bug Fixes - prevent duplicate _type fields in JSON cache for groups by [@jdx](https://github.com/jdx) in [#297](#297) - add top-level exclude property to hk.pkl by [@jdx](https://github.com/jdx) in [#299](#299) Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
1 task
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Sep 24, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [hk](https://github.com/jdx/hk) | minor | `1.13.7` -> `1.15.5` | 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.15.5`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1155---2025-09-22) [Compare Source](jdx/hk@v1.15.4...v1.15.5) ##### 🐛 Bug Fixes - ensure stash cleanup by [@​jdx](https://github.com/jdx) in [#​302](jdx/hk#302) ### [`v1.15.4`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1154---2025-09-22) [Compare Source](jdx/hk@v1.15.3...v1.15.4) ##### 🐛 Bug Fixes - scope staging to step job files to avoid unrelated file commits; add lockfile regression test by [@​jdx](https://github.com/jdx) in [#​300](jdx/hk#300) ### [`v1.15.3`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1153---2025-09-21) [Compare Source](jdx/hk@v1.15.2...v1.15.3) ##### 🐛 Bug Fixes - prevent duplicate \_type fields in JSON cache for groups by [@​jdx](https://github.com/jdx) in [#​297](jdx/hk#297) - add top-level exclude property to hk.pkl by [@​jdx](https://github.com/jdx) in [#​299](jdx/hk#299) ### [`v1.15.2`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1152---2025-09-20) [Compare Source](jdx/hk@v1.15.1...v1.15.2) ##### 🐛 Bug Fixes - prettier bugs; stash/unstash robustness; preserve EOF newline by [@​jdx](https://github.com/jdx) in [#​293](jdx/hk#293) ##### 📚 Documentation - remove references to alternative config formats by [@​jdx](https://github.com/jdx) in [5e497b6](jdx/hk@5e497b6) ### [`v1.15.1`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1151---2025-09-19) [Compare Source](jdx/hk@v1.15.0...v1.15.1) ##### 🐛 Bug Fixes - Skip any hunks that begin before the current position to avoid partial re-application by [@​jdx](https://github.com/jdx) in [8325a66](jdx/hk@8325a66) ### [`v1.15.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1150---2025-09-19) [Compare Source](jdx/hk@v1.14.0...v1.15.0) ##### 🚀 Features - **(docs)** add custom VitePress theme with unique branding by [@​jdx](https://github.com/jdx) in [#​287](jdx/hk#287) ##### 🐛 Bug Fixes - handle fixes and unstaged hunks in the same file by [@​jdx](https://github.com/jdx) in [#​283](jdx/hk#283) ##### 📦️ Dependency Updates - pin dependencies by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​288](jdx/hk#288) - update actions/checkout action to v5 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​289](jdx/hk#289) - update actions/download-artifact action to v5 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​290](jdx/hk#290) - update actions/upload-pages-artifact action to v4 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​291](jdx/hk#291) ### [`v1.14.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1140---2025-09-18) [Compare Source](jdx/hk@v1.13.7...v1.14.0) ##### 🚀 Features - centralized settings registry with codegen by [@​jdx](https://github.com/jdx) in [#​284](jdx/hk#284) ##### 🔍 Other Changes - removed snapshot file by [@​bhanuprasad14](https://github.com/bhanuprasad14) in [0952af5](jdx/hk@0952af5) - Extract Pkl error handling into separate method by [@​jdx](https://github.com/jdx) in [e62cb24](jdx/hk@e62cb24) </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:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMTYuNiIsInVwZGF0ZWRJblZlciI6IjQxLjEyMi4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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
Add support for a top-level
excludeproperty in hk.pkl configuration files to globally exclude files from all steps and hooks.exclude: (String | List<String>)?property to Config.pkl schemaStringOrListpattern for clean implementationUsage Examples
Behavior
Test Coverage
🤖 Generated with Claude Code