Skip to content

feat(commit-generation): deprecate commits squash template variable - #2985

Merged
max-sixty merged 5 commits into
mainfrom
fix/deprecate-commits-template-var
Jun 13, 2026
Merged

max-sixty merged 5 commits into
mainfrom
fix/deprecate-commits-template-var

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Collaborator

Step 1 of the deprecation cycle for the commits squash template variable, tracked in #2984 and requested in #2983 (comment).

What

commit_details (added in #2983) is a strict superset of commits. This PR makes that superset relationship total — so the deprecation can be auto-migrated by wt config update rather than requiring a hand edit.

  • Each commit_details element 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 old commits list of subject strings.

  • commits is added to the standard DEPRECATED_VARS framework. A user squash-template that still references it renders unchanged, emits the framework's one-time deprecation warning, and is rewritten by wt config update:

    ▲ User config: template variable commits is deprecated in favor of commit_details
    ↳ To see details, run wt config show; to apply updates, run wt config update
    
  • The default squash template, the variable docs, and the example config iterate commit_details and use .subject.

Design notes

The shape change is dissolved, so the rename is mechanical. The original version of this PR argued commits couldn't go through DEPRECATED_VARS because the shape changes (string → object): a template would need {{ commit }} rewritten to {{ commit.subject }} by hand. Making commit_details elements 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 in build_prompt is gone; detection and rewrite both live in the standard framework.

Implementation: a minijinja Object (CommitDetailValue) with repr = Map (for .subject / .body access) and a render override that emits the subject. minijinja coerces an object to a string via render, 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 removed commits from the docs. Note the name remains transitional per the cycle in #2984: once commits is fully retired we may re-introduce commits as the list-of-objects form, at which point commit_details would itself be deprecated.

Tests

  • test_config_update_migrates_commits_squash_var — wt config update rewrites a commits squash template to commit_details, leaving the bare loop variable untouched.
  • test_step_squash_show_prompt_commit_details_renders_subject_bare — a commit_details template printing the loop variable bare emits subjects.
  • test_step_squash_show_prompt_deprecated_commits_warns — a commits template still renders and now warns via the standard framework.
  • Help/docs snapshots and mirrors regenerated; full cargo test --test integration green (1777 passed). cargo clippy --all-targets and cargo fmt --check clean.

Follow-up (after 2026-09-06) is tracked in #2984.

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]>
@max-sixty

Copy link
Copy Markdown
Owner

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]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Yes — done, pushed in fd0c8ea.

The blocker was the shape change: commits is a list of strings, commit_details a list of {subject, body} objects, so renaming commits → commit_details would have left the loop body's bare {{ commit }} rendering an object instead of the subject. That's why the first cut warned but didn't auto-fix.

The fix dissolves the shape change instead of working around it: each commit_details element now renders as its bare subject (a minijinja Object with repr = Map for .subject/.body plus a render override emitting the subject), so {% for c in commit_details %}{{ c }} reads identically to the old {% for c in commits %}{{ c }}. minijinja coerces objects to strings through that same render, so even {{ c | upper }} stays transparent.

With the shapes equivalent, commits is just another DEPRECATED_VARS entry — the existing normalize_template_vars / wt config update machinery rewrites it as a plain identifier rename, the loop variable left bare. The bespoke render-time warning in build_prompt is gone; the warning now comes from the standard framework and points at wt config update:

▲ User config: template variable commits is deprecated in favor of commit_details
↳ To see details, run wt config show; to apply updates, run wt config update

Tests cover the migration (config update rewrites a commits template to commit_details with the loop body untouched) and the bare render (a commit_details template printing the loop variable emits subjects). PR description updated.

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]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Pushed 91613b2 to fix the failing codecov/patch: the new CommitDetailValue had three uncovered lines (repr, the get_value catch-all, and enumerate).

  • repr was redundant — the Object trait already defaults to ObjectRepr::Map, so I dropped the override (and the now-unused ObjectRepr import).
  • Added unit tests for the remaining two: an unknown attribute ({{ c.nope }} → empty, hitting the _ => None arm) and truthiness ({% if c %}, which routes through enumerate). The enumerate override matters here — without it a Map-repr object enumerates as empty and reads as falsy, which would diverge from the old non-empty subject string.

@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot please resolve conflicts

…-template-var

# Conflicts:
#	tests/integration_tests/config_show.rs
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved and pushed in f179904 (merge of main).

Two things had moved on main since this branch:

  1. The deprecation system was refactored to the DEPRECATION_RULES table (feat(hooks)!: table-form pre-* hooks run concurrently — remove the serial path #3052 and the rules-table rewrite). This branch added commits → commit_details as a plain DEPRECATED_VARS entry, and main kept that framework intact — so the rename now rides entirely on the existing UpdateOnly(migrate_template_vars_doc) row. No special-casing, exactly as intended: commits is just another row in the template-var list. The merge of src/config/deprecation.rs combined cleanly with no semantic gap.

  2. The only textual conflict was in tests/integration_tests/config_show.rs. main's feat(hooks)!: table-form pre-* hooks run concurrently — remove the serial path #3052 (table-form pre-* hooks run concurrently — remove the serial path) deleted test_config_show_displays_pre_hook_table_form_deprecation because that deprecation no longer exists. I respected the deletion and kept this branch's new test_config_update_migrates_commits_squash_var.

Verification on the merged tree:

  • test_config_update_migrates_commits_squash_var, test_step_squash_show_prompt_commit_details_renders_subject_bare, test_step_squash_show_prompt_deprecated_commits_warns — pass
  • test_warning_fires_iff_update_changes (the warning-iff-update invariant) and the full deprecation lib suite (158 tests) — pass
  • test_docs_are_in_sync — pass
  • cargo build --tests — clean

CI will run the full suite.

@max-sixty

Copy link
Copy Markdown
Owner

remove the experimental from commit_details and remove commits from documentation pls

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]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Done, pushed in 36db58e.

  • Dropped the [experimental] badge from commit_details (the after_long_help source in src/cli/mod.rs, the docs/content/llm-commits.md table, and dev/config.example.toml).
  • Removed the commits row from the template-variable documentation in all three.

This is docs-only — commits still renders for un-migrated templates and still emits the deprecation warning via the DEPRECATION_RULES framework; wt config update continues to rewrite it. The 158-test deprecation lib suite and the squash-prompt integration tests stay green, and test_docs_are_in_sync regenerated the config.md / llm-commits.md mirrors and the help snapshots.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

On the two points from the review:

@max-sixty max-sixty left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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??)

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

On the two points:

Examples already use the attribute. The default squash template, the docs table + loop example, and dev/config.example.toml all iterate with {{ detail.subject }} / {{ c.subject }} as of 36db58e — the only bare {{ commit }} left is for recent_commits, which genuinely is a list of subject strings. So the visible guidance already steers users to the attribute, not the str representation.

On having update do the full transformation instead of keeping the str representation — I looked into it, and I think render-as-subject is the better tradeoff for a concrete reason rather than just effort.

The str representation is the only thing that makes the rename a pure identifier swap. commits → commit_details rides the existing DEPRECATED_VARS machinery, which renames an identifier token. To drop the str representation, update would have to additionally rewrite every reference to the loop variable within its scope:

  • {{ c }} → {{ c.subject }}
  • {{ c | upper }} → {{ c.subject | upper }}
  • {{ commits[0] }} → {{ commit_details[0].subject }}

i.e. find the {% for X in commits %} binding, track shadowing, and rewrite only the in-scope refs. minijinja's public API has no template re-emitter, so that rewrite would be heuristic string surgery on the loop body — exactly the kind of fragile {{ var }} parsing the codebase avoids elsewhere (we use minijinja::undeclared_variables over regex precisely to dodge it). And it's user-prompt content: a mis-rewrite silently changes what's sent to the model, which is the data-safety failure mode the project tries hardest to avoid.

Render-as-subject sidesteps all of that: the rename stays a one-token swap, any old usage of the loop variable (bare, filtered, indexed, if-tested) keeps working transparently, and hand-written templates get the friendly property that bare {{ c }} "just works." The cost is one documented quirk — a commit_details element stringifies to its subject — contained to CommitDetailValue.

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 update with a test battery for the cases above — just say so and I'll take that path instead.

@max-sixty
max-sixty merged commit 0d9b9b8 into main Jun 13, 2026
37 checks passed
@max-sixty
max-sixty deleted the fix/deprecate-commits-template-var branch June 13, 2026 21:37
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants