Skip to content

Commit 9bde1b5

Browse files
committed
Merge branch 'main' into fix/issue-2101-user-alias-execute
2 parents ee3ed66 + 54d4fe7 commit 9bde1b5

55 files changed

Lines changed: 1200 additions & 559 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: test setup
2+
description: |
3+
Cargo test tooling, rust-cache, and the shells our PTY tests exercise.
4+
Used by the test matrix and the cargo-affected jobs (which add their own
5+
cargo-affected + llvm-tools steps after this).
6+
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Install cargo-insta
11+
uses: baptiste0928/cargo-install@v3
12+
with:
13+
crate: cargo-insta
14+
version: "=1.46.3"
15+
16+
- name: Install cargo-nextest
17+
uses: baptiste0928/cargo-install@v3
18+
with:
19+
crate: cargo-nextest
20+
version: "=0.9.132"
21+
22+
- name: 💰 Cache
23+
uses: Swatinem/rust-cache@v2
24+
25+
- name: Install shells (zsh, fish) - Ubuntu
26+
if: runner.os == 'Linux'
27+
uses: awalsh128/cache-apt-pkgs-action@latest
28+
with:
29+
packages: zsh fish
30+
version: 1.0
31+
32+
- name: Install shells (fish) - macOS
33+
if: runner.os == 'macOS'
34+
shell: bash
35+
run: |
36+
brew install fish
37+
# bash and zsh are pre-installed on macOS
38+
39+
- name: Install nushell
40+
if: runner.os != 'Windows'
41+
uses: hustcer/setup-nu@v3
42+
with:
43+
version: '0.112.2'

‎.github/workflows/ci.yaml‎

Lines changed: 116 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,7 @@ jobs:
8585
- name: 📂 Checkout code
8686
uses: actions/checkout@v6
8787

88-
- name: Install cargo-insta
89-
uses: baptiste0928/cargo-install@v3
90-
with:
91-
crate: cargo-insta
92-
version: "=1.46.3"
93-
94-
- name: Install cargo-nextest
95-
uses: baptiste0928/cargo-install@v3
96-
with:
97-
crate: cargo-nextest
98-
version: "=0.9.132"
99-
100-
- name: 💰 Cache
101-
uses: Swatinem/rust-cache@v2
102-
103-
- name: Install shells (zsh, fish) - Ubuntu
104-
if: runner.os == 'Linux'
105-
uses: awalsh128/cache-apt-pkgs-action@latest
106-
with:
107-
packages: zsh fish
108-
version: 1.0
109-
110-
- name: Install shells (fish) - macOS
111-
if: runner.os == 'macOS'
112-
run: |
113-
brew install fish
114-
# bash and zsh are pre-installed on macOS
115-
116-
- name: Install nushell
117-
if: runner.os != 'Windows'
118-
uses: hustcer/setup-nu@v3
119-
with:
120-
version: '0.112.2'
121-
122-
- name: Install shells - Windows
123-
if: runner.os == 'Windows'
124-
run: |
125-
# Git Bash is pre-installed on GitHub Actions Windows runners
126-
# Fish, zsh, and nushell are not commonly available on native Windows (require WSL/MSYS2)
127-
# CI will test with bash only on Windows (tests skip unavailable shells)
128-
echo "Using Git Bash for Windows tests"
129-
shell: pwsh
88+
- uses: ./.github/actions/test-setup
13089

13190
- name: Install wt
13291
uses: baptiste0928/cargo-install@v3
@@ -237,7 +196,7 @@ jobs:
237196
uses: actions/checkout@v6
238197

239198
- name: Setup Zola
240-
uses: taiki-e/[email protected].22
199+
uses: taiki-e/[email protected].27
241200
with:
242201
243202

@@ -276,6 +235,120 @@ jobs:
276235
- name: 📊 Run benchmarks
277236
run: cargo bench
278237

238+
# cargo-affected: runs only the tests whose recorded coverage overlaps the
239+
# diff. Advisory at this stage — `test (linux/macos/windows)` still runs the
240+
# full suite. The signal is the runtime delta on the exact-match path and
241+
# whether selection misses any failures the full suite catches.
242+
#
243+
# TODO: once cargo-affected is trusted on this repo, gate the full test
244+
# matrix to run only on pushes to main and on PRs with a `full-tests` label
245+
# (or similar). PR pushes would default to affected-only. The full suite
246+
# could fold into the existing `nightly` workflow, which already hosts
247+
# slower integration-time checks. Periodic full runs remain essential —
248+
# cargo-affected misses non-Rust inputs (`include_str!`, templates, SQL),
249+
# build-time inputs not in its fingerprint (build.rs, rust-toolchain.toml,
250+
# .cargo/config.toml), and proc-macro source edits.
251+
#
252+
# Cache strategy:
253+
# - `collect-affected` (push to main) saves `target/affected/` to
254+
# actions/cache keyed on the main commit sha.
255+
# - `affected-tests` (PRs) restores the cache. Primary key is the
256+
# PR/main merge-base — when collect ran on that exact commit, we get a
257+
# tight diff (`PR changes only`) and the smallest possible selection.
258+
# - Restore-keys fall back to the most recent main DB. Its `collect_sha`
259+
# may be ahead of the merge-base; cargo-affected handles that by running
260+
# all tests with a notice (no `Diverged` bail), so the fallback always
261+
# produces a useful run, just with broader selection.
262+
# - Cache keys include `runner.os` (fingerprint embeds `rustc -vV`) and a
263+
# manual `db-v{N}` marker. Bump the marker if cargo-affected ships an
264+
# on-disk schema change; the cache is otherwise version-agnostic.
265+
collect-affected:
266+
name: collect affected coverage
267+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' }}
268+
runs-on: ubuntu-24.04
269+
steps:
270+
- name: 📂 Checkout code
271+
uses: actions/checkout@v6
272+
with:
273+
# `cargo affected run` later diffs PR HEAD against the sha that was
274+
# HEAD when collect ran. That sha must be reachable.
275+
fetch-depth: 0
276+
277+
- uses: ./.github/actions/test-setup
278+
279+
- name: Install cargo-affected
280+
uses: baptiste0928/cargo-install@v3
281+
with:
282+
crate: cargo-affected
283+
git: https://github.com/max-sixty/cargo-affected
284+
# No rev/branch/tag → action resolves to latest default-branch sha.
285+
286+
- name: Install llvm-tools
287+
run: rustup component add llvm-tools
288+
289+
- name: 📊 Collect coverage data
290+
env:
291+
NEXTEST_NO_INPUT_HANDLER: 1
292+
run: cargo affected collect --features shell-integration-tests
293+
294+
- name: 💾 Save coverage DB
295+
uses: actions/cache/save@v5
296+
with:
297+
path: target/affected
298+
key: cargo-affected-db-v1-${{ runner.os }}-${{ github.sha }}
299+
300+
affected-tests:
301+
name: affected tests (linux, advisory)
302+
if: github.event_name == 'pull_request'
303+
runs-on: ubuntu-24.04
304+
# Advisory while we calibrate selection accuracy against the full suite.
305+
# The full matrix (`test (linux/macos/windows)`) is still required for
306+
# merge.
307+
continue-on-error: true
308+
steps:
309+
- name: 📂 Checkout code
310+
uses: actions/checkout@v6
311+
with:
312+
# Need the cached `collect_sha` reachable from HEAD for the diff;
313+
# see collect-affected above.
314+
fetch-depth: 0
315+
316+
- name: Compute merge-base for cache key
317+
id: mb
318+
env:
319+
PR_HEAD: ${{ github.event.pull_request.head.sha }}
320+
run: |
321+
git fetch --no-tags --depth=200 origin main
322+
sha=$(git merge-base origin/main "$PR_HEAD")
323+
echo "sha=$sha" >> "$GITHUB_OUTPUT"
324+
echo "merge-base with origin/main: $sha"
325+
326+
- name: 💾 Restore coverage DB
327+
uses: actions/cache/restore@v5
328+
with:
329+
path: target/affected
330+
# Exact match: collect ran on the PR's merge-base → tight diff.
331+
key: cargo-affected-db-v1-${{ runner.os }}-${{ steps.mb.outputs.sha }}
332+
# Fallback: most recent main DB. cargo-affected runs all tests when
333+
# collect_sha isn't an ancestor of HEAD; with no DB at all it does
334+
# the same. Either way the run produces a useful signal.
335+
restore-keys: |
336+
cargo-affected-db-v1-${{ runner.os }}-
337+
338+
- uses: ./.github/actions/test-setup
339+
340+
- name: Install cargo-affected
341+
uses: baptiste0928/cargo-install@v3
342+
with:
343+
crate: cargo-affected
344+
git: https://github.com/max-sixty/cargo-affected
345+
# No rev/branch/tag → action resolves to latest default-branch sha.
346+
347+
- name: 🎯 Run affected tests
348+
env:
349+
NEXTEST_NO_INPUT_HANDLER: 1
350+
run: cargo affected run --features shell-integration-tests --verbose
351+
279352
code-coverage:
280353
runs-on: ubuntu-24.04
281354
steps:

‎.github/workflows/nightly.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: Swatinem/rust-cache@v2
4141

4242
- name: Install cargo-hack
43-
uses: taiki-e/[email protected].22
43+
uses: taiki-e/[email protected].27
4444
with:
4545
tool: cargo-hack
4646

‎.github/workflows/publish-docs.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v6
2424

2525
- name: Setup Zola
26-
uses: taiki-e/[email protected].22
26+
uses: taiki-e/[email protected].27
2727
with:
2828
2929

‎CHANGELOG.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Changelog
22

3+
## 0.46.0
4+
5+
### Improved
6+
7+
- **`sanitize_db` template filter caps output at 48 chars** (was 63 — PostgreSQL's identifier limit). The new budget leaves headroom for users composing the output into longer paths or identifiers, e.g., Unix socket paths capped at 107 bytes. The 3-character hash suffix is unchanged, so collision avoidance is preserved at the new budget; only the truncated base shrinks. (Breaking: branches whose previous `sanitize_db` output exceeded 48 chars get a different identifier — most names are well under 48 and pass through unchanged.) ([#2467](https://github.com/max-sixty/worktrunk/pull/2467), thanks @yajo for [#2397](https://github.com/max-sixty/worktrunk/issues/2397))
8+
9+
- **New `hash` template filter**: `{{ value | hash }}` produces a 3-character base36 digest of the input — useful for composing custom truncate-with-collision-avoidance recipes when `sanitize_db`'s 48-char budget still isn't tight enough. ([#2453](https://github.com/max-sixty/worktrunk/pull/2453))
10+
11+
- **Background hook announces collapse to one line per command**: `wt merge` (with removal) previously emitted two or three separate `◎ Running …` lines for `post-remove + post-switch` and `post-merge`. Hooks across all phases of a single command now share one combined announce: `◎ Running post-remove: user:cleanup; post-switch: user:notify; post-merge: user:sync`. ([#2457](https://github.com/max-sixty/worktrunk/pull/2457))
12+
13+
- **Picker-driven `post-switch` hooks now receive `target` / `target_worktree_path`** template variables, matching hooks fired from `wt switch <branch>`. Closes a pre-existing asymmetry where interactive switching exposed strictly fewer variables than the non-interactive path. ([#2470](https://github.com/max-sixty/worktrunk/pull/2470))
14+
15+
### Fixed
16+
17+
- **`wt <alias>` stdout is pipeable again**: `wt my-alias | tr …` (and any other downstream pipe) silently produced no output because the foreground executor redirected every alias body's stdout to wt's stderr — a hook-only redirect that PR [#2089](https://github.com/max-sixty/worktrunk/pull/2089) inherited uniformly. Aliases now pass stdout through; hooks and `wt step for-each` keep the merged-stderr behavior so their output stays ordered with wt's own status messages. ([#2479](https://github.com/max-sixty/worktrunk/pull/2479), thanks @davidmyersdev for reporting [#2478](https://github.com/max-sixty/worktrunk/issues/2478))
18+
19+
- **`wt switch <symlink>` resolves to the existing worktree** instead of failing with `No branch named …`. The path-based fallback in `Repository::worktree_at_path` previously compared paths via lexical normalization only, so symlink-equivalent spellings never matched. The same symlink-aware comparison is now used everywhere the library identifies a worktree by path. ([#2466](https://github.com/max-sixty/worktrunk/pull/2466))
20+
21+
- **Deleted-CWD recovery handles symlinked subdirectories**: When a worktree is removed while a shell sits in a subdirectory whose parents include a symlink (e.g. `~/link/repo.feature/src`), `wt` now finds the parent repository and recovers as expected. Previously the symlink-aware path compared only file names and bailed for any path deeper than the worktree root. ([#2464](https://github.com/max-sixty/worktrunk/pull/2464))
22+
23+
- **Merge safety backups for slash branches**: `WorkingTree::create_safety_backup()` flattened `/` to `-` in the ref path, so distinct branches like `a/b` and `a-b` collided at the same `refs/wt-backup/a-b` ref — the latest backup for one could clobber the other, and the documented `refs/wt-backup/<branch>` recovery path didn't match what was actually written. Slashes are valid in git ref names; the branch name is now used as-is. ([#2463](https://github.com/max-sixty/worktrunk/pull/2463))
24+
25+
- **Nushell wrapper migrates to function-level `@complete`**: Per fdncred's recommendation in [nushell/nushell#18128](https://github.com/nushell/nushell/issues/18128), the wrapper replaces the parameter-level `[...args: string@"nu-complete wt"]` with a function-level `@complete` attribute on an untyped `[...args]` rest, and the completer signature moves from `[context: string]` (with manual `split row " "` reconstruction) to `[spans: list<string>]`. Net deletion of seven lines of fragile token reassembly; once [nushell/nushell#18131](https://github.com/nushell/nushell/issues/18131) ships in stable nu the wrapper will automatically benefit from `--flag="value"` quote stripping and `~` expansion. ([#2458](https://github.com/max-sixty/worktrunk/pull/2458))
26+
27+
### Internal
28+
29+
- **Hook dispatch unified**: A single `HookAnnouncer` orchestrates per-command announces across phases, replacing scattered `CommandOrigin`-keyed dispatch with closures, and the various background-hook entry points now share one path. Switch and merge sites assemble template variables through a single `TemplateVars` builder. ([#2457](https://github.com/max-sixty/worktrunk/pull/2457), [#2470](https://github.com/max-sixty/worktrunk/pull/2470), [#2472](https://github.com/max-sixty/worktrunk/pull/2472), [#2477](https://github.com/max-sixty/worktrunk/pull/2477))
30+
31+
- **`wt list` rendering modes collapse**: The internal `RenderTarget` enum replaces three parallel rendering paths, the JSON path skips the per-result render that the formatter never used, and dead `is_tty` plumbing is removed. ([#2469](https://github.com/max-sixty/worktrunk/pull/2469), [#2473](https://github.com/max-sixty/worktrunk/pull/2473))
32+
33+
- **Push handling switches to a `PushKind` enum** instead of sniffing verb strings ([#2468](https://github.com/max-sixty/worktrunk/pull/2468)); `try_alias` and `step_alias` share one help-intercept implementation ([#2471](https://github.com/max-sixty/worktrunk/pull/2471)); lazy template expansion in the command executor lives in one place via `resolve_command_str` ([#2476](https://github.com/max-sixty/worktrunk/pull/2476)).
34+
335
## 0.45.2
436

537
### Fixed

‎CLAUDE.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ cargo bench --bench list bench_list_by_worktree_count # specific benchmark
305305

306306
Real repo benchmarks clone rust-lang/rust (~2-5 min first run, cached thereafter). Skip with `--skip real`. See `benches/CLAUDE.md` for methodology and adding new benchmarks.
307307

308+
### Don't wait for CI `benchmarks` before merging
309+
310+
The `benchmarks` job is non-required — only `test (linux)`, `test (macos)`, and `test (windows)` block merge. Bench runs can take 80+ minutes (the `rust-lang/rust` clone plus a full `cargo bench`) and are often still pending when required checks have already passed. `gh pr view` reports `mergeStateStatus: UNSTABLE` in that state — that's mergeable, and it's generally fine to merge without waiting.
311+
308312
## JSON Output Format
309313

310314
Use `wt list --format=json` for structured data access. See `wt list --help` for complete field documentation, status variants, and query examples.

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ default-members = [".", "tests/helpers/mock-stub", "tests/helpers/wt-perf"]
55

66
[package]
77
name = "worktrunk"
8-
version = "0.45.2"
8+
version = "0.46.0"
99
edition = "2024"
1010
rust-version = "1.94"
1111
build = "build.rs"

‎docs/static/.well-known/agent-skills/index.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎skills/worktrunk/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: worktrunk
33
description: Guidance for Worktrunk (the `wt` CLI) — git worktree management, hooks, and config. Load when editing .config/wt.toml or ~/.config/worktrunk/config.toml; adding, modifying, or debugging hooks (post-merge, post-start, pre-commit, pre-merge, post-switch, etc.); configuring commit message generation or command aliases; or troubleshooting wt behavior. Also answers general worktrunk/wt questions.
4-
version: 0.45.2
4+
version: 0.46.0
55
license: MIT OR Apache-2.0
66
compatibility: Requires worktrunk CLI (https://worktrunk.dev)
77
---

0 commit comments

Comments
 (0)