Repository navigation
fix: use underscores in db_url var key examples - #1848
Merged
Merged
Conversation
Hyphens in var keys conflict with Jinja2 expression parsing — `vars.db-url` is interpreted as `vars.db` minus `url`. Underscores avoid the ambiguity. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 1, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 26, 2026
…ipes wt rejects (#4279) Two recipes on the Tips & Patterns page fail when copied. This PR fixes both, adds a test that runs the database recipe straight from the page, and makes the hook-output JSON report real branch names so the log recipes can scope to the current branch. - **Database per worktree**: the `set-vars` step passed three `KEY=VALUE` pairs to one `wt config state vars set`, which accepts exactly one (`error: unexpected argument 'port=…' found`). Because the step failed, `vars.container` and `vars.port` were never set for the `db` step or `pre-remove`. The step now runs three `vars set` calls chained with `&&`. The recipe also stored `db_url`, and vars keys have rejected underscores since #2285 (Git config variable names can't contain them). It's now `db-url`, in the `vars get` example too. #1848 had moved this key from hyphens to underscores because Jinja parses `vars.db-url` as subtraction. That doesn't apply here: the recipe reads the key only with `wt config state vars get db-url`, never in a template. - **Monitor hook logs**: `wt config state logs get --hook=user:post-start:server` and the `wtlog` alias built on it fail with `unexpected argument '--hook'`, because #2161 removed that flag. Its replacement, a `jq` filter over `wt config state logs --format=json`, couldn't scope to the current branch. The JSON `branch` field was the sanitized log directory (`feature/x` became `feature-x-<hash>`), so the help example used `startswith` and `head -1` and tailed whichever worktree's `server` log was newest. - **Hook-output JSON `branch`**: the field now holds the real branch name. It maps each log directory back through `sanitize_for_filename` over the local branches, and is `null` when no local branch writes there: a deleted branch, a detached HEAD, or a directory two branches share. The recipes in the help and on the page match `[.branch, .source, .hook_type, .name]` exactly. The extending page's `hook-log` alias compared `.branch` with `{{ branch | sanitize_hash }}`, the on-disk form, and now passes `{{ branch }}` to jq with `--arg`, like its other values. The `wtlog` alias becomes a shell function taking the hook name. `test_doc_example_database_set_vars_step_runs` pulls the `set-vars` step from the page's TOML block, runs it as a `wt` alias with `wt` on `PATH`, and checks the stored `port`. It fails on `main` with the argument error above. After the first fix it also caught the `db_url` rejection. `test_logs_get_json_branch_is_unsanitized` covers the branch mapping, including the deleted and shared-directory cases. I ran the new recipe by hand from a `feature/x` worktree next to an `other/y` worktree, and it tailed only the `feature/x` log. The `skills/` and `plugins/` copies of the page are regenerated by `test_docs_are_in_sync`. --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Maximilian Roos <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Hyphens in var keys conflict with Jinja2 expression parsing —
vars.db-urlis interpreted asvars.dbminusurl. Renameddb-urltodb_urlin the database examples in hook docs and tips-patterns.