Skip to content

fix: support multi-path scope values in [_.codebase.scope]#56

Open
olavostauros wants to merge 1 commit into
KnickKnackLabs:mainfrom
olavostauros:fix/multi-path-scope
Open

fix: support multi-path scope values in [_.codebase.scope]#56
olavostauros wants to merge 1 commit into
KnickKnackLabs:mainfrom
olavostauros:fix/multi-path-scope

Conversation

@olavostauros

@olavostauros olavostauros commented Jun 22, 2026

Copy link
Copy Markdown

Summary

Fixes the _.codebase.scope TOML configuration parser so that multi-path scope values (e.g., or-true = ".mise/tasks lib") expand to separate targets instead of being corrupted into a single garbage path.

Previously, codebase_target_for_rule() emitted the entire scope value as one string, producing a target like /repo/.mise/tasks lib (with an embedded space). This either errored (path doesn't exist) or silently scanned nothing — giving users false confidence that they had multi-path coverage.

Changes

File Change
lib/codebase-config.sh Replaced codebase_target_for_rule with codebase_targets_for_rule. Splits the scope value on whitespace via shell word-splitting (unquoted $scope in a for loop), emitting one target line per token. Each token is resolved as a relative path against $repo_root, or passed through if absolute.
.mise/tasks/lint/_default Iterates over the multi-line output so each target is linted independently.
test/lint/default.bats Added lint: honors multi-path scope (space-separated targets) test.

Design decisions

  • Word-splitting on unquoted $scope — TOML string values like ".mise/tasks lib" return .mise/tasks lib from mise config get (quotes stripped, space preserved). Shell word-splitting naturally splits this into .mise/tasks and lib.
  • Backward compatible — Single-path scopes (the common case, e.g., gum-table = "scripts") emit one line as before. The dot/empty case still maps to the repo root directly.
  • No changes to pre-commit hook — The hook delegates to codebase lint, which now handles the iteration internally.

Validation

Fixes #22

The codebase_target_for_rule() function treated the entire scope value as
a single path, so a TOML string like or-true = ".mise/tasks lib" would
produce a single target /repo/.mise/tasks lib (with space) instead of
two separate targets /repo/.mise/tasks and /repo/lib.

This meant multi-path scope overrides either errored (path doesn't exist)
or silently scanned nothing — users thought they had multi-path coverage
but got false passes.

Changes:
- lib/codebase-config.sh: Replace codebase_target_for_rule() with
  codebase_targets_for_rule() that splits the scope value on whitespace
  and emits one target line per token.
- .mise/tasks/lint/_default: Iterate over the multi-line output so each
  target is linted independently.
- test/lint/default.bats: Add test covering multi-path scope with
  space-separated path list.

The fix uses shell word-splitting on the scope string (unquoted  in
a for loop), which naturally handles TOML string values with internal spaces.
Each token is resolved as a relative path against the repo root, or passed
through unchanged if absolute.

Fixes KnickKnackLabs#22
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.

Bug: [_.codebase.scope] parser strips internal spaces, corrupting multi-path scopes

1 participant