Repository navigation
fix(mfile): bind repo-wide params into task command interpolation - #1980
Conversation
File::hydrate_task_defaults now merges each [params] entry into the
task's args unless the task declares an arg of the same name, so a
command can read a repo param as %{name} and override it with --name.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughRepository-wide parameters are added to task arguments as defaults when a task does not define an argument with the same name. Tests cover interpolation and command-line overrides. Documentation describes how to define and use these parameters. ChangesRepository Parameter Defaults
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is identified; the change is ready for normal merge checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit reads the params file, Comment |
|
Approved: no findings at Nothing to do. Clobber: none: |
Problem
docs/reference/minimal-dot-toml.mdsays repo-wide[params]are available to tasks across the repository, but task commands never saw them. Withmin task run useparamfailed withnickel eval failed for string: echo greeting=%{greeting}, and the attached note wrongly suggested escaping the%{. There was also no way to override a param on the command line.Task interpolation (
mctx::interpolate_task_strings) binds onlytask_packagesand the task's parsed args, andFile::hydrate_task_defaultsapplied the repo's default profile, state key and stack packages to a task but not its params.Fix
File::hydrate_task_defaults(crates/mfile) merges each[params]entry intotask.argsunless the task already declares an arg of that name, so a task arg shadows a repo param. Every param must carry a default, so the merged entries are optional args: every path that parses a task's args now binds them, applying the default or a--<name>override.[params]section ofdocs/reference/minimal-dot-toml.mdnow states that params act as defaulted args on every task and that a task arg of the same name wins.Tests
crates/mfile:task_inherits_repo_params_as_args:File::taskreturns the param as an arg with its default, and a task arg of the same name is kept.crates/mctx:interpolate_resolves_hydrated_repo_param:echo %{greeting}resolves toecho hiwith an empty argv and toecho byewith--greeting bye.Commands run (macOS arm64 host, pinned toolchain 1.97.0):
cargo fmt --check: clean.just test-one task_inherits_repo_params_as_args -p mfile: 1 passed.cargo clippy -p mfile --all-targets --locked -- -D warnings: clean.mctxdoes not build natively on macOS, so it ran through cross (musl in Docker):CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p mctx -p mfile --target aarch64-unknown-linux-musl --locked: mctx 44 passed, 3 ignored; mfile 66 passed; 0 failed.CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p mctx --target aarch64-unknown-linux-musl --locked -- interpolate_: 3 passed, including the new test.CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross clippy -p mctx -p mfile --all-targets --target aarch64-unknown-linux-musl --locked -- -D warnings: clean.just lint-prose docs/reference/minimal-dot-toml.md: no alerts on the changed lines.Refs gominimal/inbox#871
Summary by CodeRabbit