Repository navigation
feat(commit-generation): deprecate commits squash template variable - #2985
Conversation
Step 1 of the deprecation cycle tracked in #2984. `commit_details` (added in #2983) is a strict superset of `commits`: `{{ detail.subject }}` reproduces the bare subject string `commits` gave, and `.body` is newly available. Converge on the richer variable. - Switch the default squash template, docs, and example config to iterate `commit_details` and use `.subject`. - A user squash template that still references `commits` renders as before but emits a one-time deprecation warning steering toward `commit_details`. The warning lives at template-render time (`build_prompt`), detected via `undeclared_variables` so `recent_commits` and `{% raw %}` blocks don't false-positive. This is deliberately not wired into the config-deprecation framework / `wt config update`: the shape changes (string → object), so a template must change `{{ commit }}` to `{{ commit.subject }}` by hand — it is not a mechanical identifier rename like the existing `DEPRECATED_VARS`. Render-time detection also matches where #2984 step 2 will later `bail!`. `commit_details` keeps its experimental badge: its name is transitional, to eventually be repurposed as `commits` once the old meaning is fully retired. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
we really want to auto-generate the fixes; can we do that? |
Make `commit_details` elements render as their bare subject (a minijinja `Object` with `repr=Map` plus a `render` override) so a template iterating the list and printing the loop variable directly behaves exactly like the old `commits` list of subject strings. `.subject`/`.body` stay available, and string filters coerce through the same `render`. That equivalence turns `commits` -> `commit_details` into a safe mechanical identifier rename, so deprecation now flows through the standard `DEPRECATED_VARS` framework: the warning and the `wt config update` rewrite are auto-generated, replacing the bespoke render-time warning in `build_prompt`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Yes — done, pushed in fd0c8ea. The blocker was the shape change: The fix dissolves the shape change instead of working around it: each With the shapes equivalent, Tests cover the migration ( |
Drop the redundant `repr` override (the `Object` trait already defaults
to `ObjectRepr::Map`) and add unit tests exercising the previously
uncovered paths: the `get_value` unknown-key arm and `enumerate`
(via `{% if c %}` truthiness, which the override keeps non-empty).
Closes the codecov/patch gap on src/llm.rs.
Co-Authored-By: Claude <[email protected]>
|
Pushed 91613b2 to fix the failing
|
|
@worktrunk-bot please resolve conflicts |
…-template-var # Conflicts: # tests/integration_tests/config_show.rs
|
Conflicts resolved and pushed in f179904 (merge of Two things had moved on
Verification on the merged tree:
CI will run the full suite. |
|
remove the experimental from |
Per maintainer request: remove the [experimental] badge from commit_details and remove the deprecated commits variable from the template-variable documentation. The commits variable still renders and still warns via the deprecation framework — this is a docs-only change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Done, pushed in 36db58e.
This is docs-only — |
worktrunk-bot
left a comment
There was a problem hiding this comment.
The CommitDetailValue approach is clean — making commit_details elements render as their bare subject genuinely dissolves the shape change, so the rename drops into the existing DEPRECATED_VARS machinery with no special-casing, and the truthiness/render overrides are both covered by tests. Migration, render, and warning paths are all snapshot- or assertion-tested. One design question and one description nit:
Dropping the experimental badge on a transitional name. The final commit (36db58e) removes the experimental badge from commit_details across the docs, help, and example config — promoting it to a stable-looking variable. But per #2984, step 3, commit_details is explicitly transitional: "once commits is fully retired, optionally re-introduce commits as the list-of-objects form (aliasing commit_details)." The roadmap is to eventually move users back onto commits. Removing the experimental badge now signals durability for a name the plan intends to deprecate again — users who build configs around commit_details would face a second migration. The badge is exactly the "don't depend on this name yet" signal. Worth a maintainer call on whether to keep it until the name settles. (@max-sixty)
Stale design note in the PR body. The "Design notes" section still says "commit_details keeps its experimental badge. Its name is transitional…" — which contradicts the final commit that drops the badge. Whichever way the question above lands, the description should be reconciled with the diff.
For context, neither concern is a correctness issue and CI is green (codecov/patch passed). Flagging the badge decision rather than approving since it's a judgment call about API-stability signaling.
|
On the two points from the review:
|
max-sixty
left a comment
There was a problem hiding this comment.
can we avoid using the str represtation on the tuple in examples? I think it's a bit awkward and instead should use the attribute
we only keep the str representation for backward compat (unless we could have update do the full transformation, which would be better and avoid the need for the str representation??)
|
On the two points: Examples already use the attribute. The default squash template, the docs table + loop example, and On having The str representation is the only thing that makes the rename a pure identifier swap.
i.e. find the Render-as-subject sidesteps all of that: the rename stays a one-token swap, any old usage of the loop variable (bare, filtered, indexed, So my recommendation is to keep it as-is. But if you'd rather eat the complexity to get a plain object with no string coercion, I'm happy to implement the scope-aware rewrite in |
worktrunk 0.59.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Picker frees digit keys for filtering; preview tabs move to `Alt`**: In the `wt switch` picker, plain digits now go to the filter, so a branch name with a number in it can be typed directly. Preview tabs jump with `Alt-1`–`Alt-5` or cycle with `Tab`/`Shift-Tab`. (Breaking: `1`–`5` no longer switch preview tabs) ([#3079](max-sixty/worktrunk#3079)) - **Squash templates use `commit_details` instead of `commits`**: The squash commit-message template's `{{ commits }}` variable (commit subjects) is deprecated in favor of `{{ commit_details }}`, which renders as the bare subject when printed directly and also exposes `.subject` and `.body`. `wt config update` migrates `commits` to `commit_details` as a plain rename. ([#2985](max-sixty/worktrunk#2985)) - **`wt step eval -v` lists template variables**: `wt step eval -v` now prints the available template variables on stderr in the gutter style, above the template-expansion view. That expansion (also shown by `wt switch -v`, hooks, aliases, and `wt -v list`) renders the template and its result as separate labeled `source` / `result` blocks rather than a shared gutter. The result still goes to stdout, so `$(wt step eval …)` is unchanged. Since `eval` mutates nothing and is experimental, its `--dry-run` flag (which dumped the raw variable context) is removed rather than deprecated. ([#3078](max-sixty/worktrunk#3078), [#3099](max-sixty/worktrunk#3099)) ### Fixed - **Picker no longer freezes on the first keystroke**: With many worktrees, typing the first character in the `wt switch` picker locked the UI for several seconds. The fuzzy matcher shares rayon's global thread pool with worktrunk's git collection, which floods it with blocking subprocess calls, so the matcher queued behind them. Collection and preview work now run on a dedicated pool, keeping the matcher responsive. ([#3087](max-sixty/worktrunk#3087), thanks @bendrucker; fixes [#2926](max-sixty/worktrunk#2926), thanks @mahume for reporting) - **Tab-completion covers all hook types**: `wt hook <type> <Tab>` completed configured command names for only seven of the ten hook types; `pre-switch`, `post-switch`, and `post-remove` returned nothing. Completion now derives the type from the canonical hook list, so every type completes its command names. ([#3070](max-sixty/worktrunk#3070)) - **Ctrl-C on a concurrent alias reports the right exit code**: Interrupting `wt step <concurrent-alias>` could report exit 143 (SIGTERM) instead of 130 (SIGINT), because a per-child SIGINT → SIGTERM → SIGKILL escalation could land a SIGTERM on a child during the grace window; the escalation also serialized across process groups, so repeated Ctrl-C could wait. wt now forwards the user's signal once per process group, so a cooperative child dies from the signal actually sent (130 on Ctrl-C); a second signal kills any survivor immediately. ([#3075](max-sixty/worktrunk#3075)) ### Documentation - **Per-worktree env vars**: A Tips & Patterns section shows how to give each worktree its own environment variables with direnv or mise. ([#3074](max-sixty/worktrunk#3074)) ### Internal - The commit-generation command is not rewritten to disk when its value is unchanged. ([#3084](max-sixty/worktrunk#3084)) ## Install worktrunk 0.59.0 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-installer.sh | sh && wt config shell install ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-installer.ps1 | iex"; git-wt config shell install ``` ### Install prebuilt binaries via Homebrew ```sh brew install worktrunk && wt config shell install ``` ## Download worktrunk 0.59.0 | File | Platform | Checksum | |--------|----------|----------| | [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) | | [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) | | [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) | ### Install via Cargo ```sh cargo install worktrunk && wt config shell install ``` ### Install via Winget (Windows) ```sh winget install max-sixty.worktrunk && git-wt config shell install ``` ### Install via AUR (Arch Linux) ```sh paru worktrunk-bin && wt config shell install ``` </pre> <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.59.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.59.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11836
Step 1 of the deprecation cycle for the
commitssquash template variable, tracked in #2984 and requested in #2983 (comment).What
commit_details(added in #2983) is a strict superset ofcommits. This PR makes that superset relationship total — so the deprecation can be auto-migrated bywt config updaterather than requiring a hand edit.Each
commit_detailselement now renders as its bare subject ({{ detail }}yields the subject line) while still exposing.subject/.body. So a template that iterates the list and prints the loop variable directly behaves exactly like the oldcommitslist of subject strings.commitsis added to the standardDEPRECATED_VARSframework. A usersquash-templatethat still references it renders unchanged, emits the framework's one-time deprecation warning, and is rewritten bywt config update:The default squash template, the variable docs, and the example config iterate
commit_detailsand use.subject.Design notes
The shape change is dissolved, so the rename is mechanical. The original version of this PR argued
commitscouldn't go throughDEPRECATED_VARSbecause the shape changes (string → object): a template would need{{ commit }}rewritten to{{ commit.subject }}by hand. Makingcommit_detailselements render as their subject removes that gap entirely —{% for c in commit_details %}{{ c }}reads identically to the old{% for c in commits %}{{ c }}, so the existing identifier-rename machinery (normalize_template_vars/wt config update) handles it with no special-casing. The bespoke render-time warning inbuild_promptis gone; detection and rewrite both live in the standard framework.Implementation: a minijinja
Object(CommitDetailValue) withrepr = Map(for.subject/.bodyaccess) and arenderoverride that emits the subject. minijinja coerces an object to a string viarender, so string filters ({{ c | upper }}) operate on the subject too — the rename stays transparent across filter usages, not just bare prints.commit_details's experimental badge was dropped (final commit 36db58e), per the maintainer's request in #2985 (comment), which also removedcommitsfrom the docs. Note the name remains transitional per the cycle in #2984: oncecommitsis fully retired we may re-introducecommitsas the list-of-objects form, at which pointcommit_detailswould itself be deprecated.Tests
test_config_update_migrates_commits_squash_var—wt config updaterewrites acommitssquash template tocommit_details, leaving the bare loop variable untouched.test_step_squash_show_prompt_commit_details_renders_subject_bare— acommit_detailstemplate printing the loop variable bare emits subjects.test_step_squash_show_prompt_deprecated_commits_warns— acommitstemplate still renders and now warns via the standard framework.cargo test --test integrationgreen (1777 passed).cargo clippy --all-targetsandcargo fmt --checkclean.Follow-up (after 2026-09-06) is tracked in #2984.