Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Set deterministic terminal width for tests (#63)
Maximilian Roos26d15e9ea5da
diff --git a/.cargo/config.toml b/.cargo/config.tomlnew file mode 100644index 000000000..badb950bb--- /dev/null+++ b/.cargo/config.toml@@ -0,0 +1,5 @@+# Set terminal width for deterministic test output.+# Unit tests call get_terminal_width() in-process and need this env var.+# Integration tests override with COLUMNS=150 in their command setup.+[env]+COLUMNS = "80"diff --git a/dev/wt-demo-build.py b/dev/wt-demo-buildsimilarity index 100%rename from dev/wt-demo-build.pyrename to dev/wt-demo-builddiff --git a/dev/wt-demo/CLAUDE.md b/dev/wt-demo/CLAUDE.mdindex 5ffe7cc4a..8c09c3854 100644--- a/dev/wt-demo/CLAUDE.md+++ b/dev/wt-demo/CLAUDE.md@@ -2,25 +2,26 @@## Running the Demo-Build and record the demo GIF:-```console-python3 dev/wt-demo-build.py+./dev/wt-demo-build```-This creates:-- `dev/wt-demo/out/wt-demo.gif` - The animated demo-- `dev/wt-demo/out/run.txt` - Text log of the output+Creates:+- `dev/wt-demo/out/wt-demo.gif` - Animated demo (~1.9 MB)+- `dev/wt-demo/out/run.txt` - Text transcript+- `dev/wt-demo/out/record.log` - Recording log++The script creates a fresh temp repo under `dev/wt-demo/out/.demo-*/`, seeds 4 worktrees + 2 extra branches, shows `wt list`, creates a worktree, edits a file, merges with `wt merge`, then shows `wt list --branches --full`.## Viewing Results**Do NOT use `open` on the GIF** - that's for the user to do manually.-To inspect what the demo produces:-- Read `dev/wt-demo/out/run.txt` to see the text output-- The GIF can be viewed in a browser or image viewer by the user+Inline viewing options:+- Quick Look: `qlmanage -p dev/wt-demo/out/wt-demo.gif`+- iTerm2: `imgcat dev/wt-demo/out/wt-demo.gif`-Claude Code cannot view GIFs directly. Use `run.txt` for verification.+For Claude Code: read `dev/wt-demo/out/run.txt` to see text output (cannot view GIFs directly).## Prerequisites@@ -34,6 +35,9 @@ Claude Code cannot view GIFs directly. Use `run.txt` for verification.## Files- `demo.tape` - VHS tape file with recording script-- `wt-demo-build.py` - Python build script that sets up demo repo and records- `fixtures/` - Extracted content files (README, lib.rs, etc.)- `out/` - Output directory (gitignored)++## Defaults++Light theme (GitHub-light-inspired palette), starship prompt, 1600x720 window.diff --git a/dev/wt-demo/README.md b/dev/wt-demo/README.mddeleted file mode 100644index 191e2685e..000000000--- a/dev/wt-demo/README.md+++ /dev/null@@ -1,10 +0,0 @@-# wt demo assets (VHS)--- Primary asset: `dev/wt-demo/out/wt-demo.gif` (regenerated by the script; ~1.9 MB).-- VHS tape: `dev/wt-demo/demo.tape` (edit this to adjust the recording).-- Text transcript: `dev/wt-demo/out/run.txt` (captured from a clean run parallel to the GIF).-- Regenerate everything with `./dev/wt-demo-build.sh` (depends on `wt`, `vhs`, `starship`).-- Script creates a fresh temp repo under `dev/wt-demo/out/demo/` (gitignored), seeds 4 worktrees + 2 extra branches, shows `wt list --branches --full`, creates another worktree, edits a file (pre-commit hook visible during merge auto-commit), merges with `wt merge`, then shows the final list.-- Defaults: light theme (GitHub-light-inspired palette), starship prompt, 1280x720 window. Worktree paths appear as `./wt-demo*` inside the session container for readability.-- Inline viewing: `qlmanage -p dev/wt-demo/out/wt-demo.gif` (Quick Look) or `imgcat dev/wt-demo/out/wt-demo.gif` in iTerm2.-- Recording log: `dev/wt-demo/out/record.log`.diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 92597b9e9..074084838 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -114,11 +114,13 @@ fn delete_branch_if_safe(/// Handle the result of a branch deletion attempt.///-/// Shows appropriate warnings for non-deleted branches.+/// Shows appropriate messages for non-deleted branches:+/// - `Ok(None)`: We checked and chose not to delete (not integrated) - show info+/// - `Err(e)`: Git command failed - show warning with actual error////// Returns:/// - `Ok(Some(reason))` if branch was deleted (reason is None if force-deleted)-/// - `Ok(None)` if branch was not deleted (warning shown)+/// - `Ok(None)` if branch was not deletedfn handle_branch_deletion_result(result: anyhow::Result<Option<Option<IntegrationReason>>>,branch_name: &str,@@ -126,19 +128,14 @@ fn handle_branch_deletion_result(match result {Ok(Some(reason)) => Ok(Some(reason)), // Deleted (with or without integration reason)Ok(None) => {- // Branch not integrated - show warning- super::warning(cformat!(- "<yellow>Could not delete branch <bold>{branch_name}</></>"- ))?;- super::gutter(format_with_gutter(- &format!("error: the branch '{}' is not fully merged", branch_name),- "",- None,+ // Branch not integrated - we chose not to delete (not a failure)+ super::info(cformat!(+ "<bright-black>Branch <bold>{branch_name}</> retained; not integrated into HEAD</>"))?;Ok(None)}Err(e) => {- // Git command failed - show warning with error details+ // Git command failed - show warning with actual error detailssuper::warning(cformat!("<yellow>Could not delete branch <bold>{branch_name}</></>"))?;@@ -387,9 +384,9 @@ fn handle_branch_only_output(no_delete_branch: bool,force_delete: bool,) -> anyhow::Result<()> {- // Show info message that no worktree was found- super::info(cformat!(- "<bright-black>No worktree found for branch {branch_name}</>"+ // Warn that no worktree was found (user asked to remove it)+ super::warning(cformat!(+ "<yellow>No worktree found for branch <bold>{branch_name}</></>"))?;// Attempt branch deletion (unless --no-delete-branch was specified)@@ -404,11 +401,7 @@ fn handle_branch_only_output(let integration_reason = handle_branch_deletion_result(result, branch_name)?;if integration_reason.is_some() {- let flag_note = if force_delete {- " (--force-delete)"- } else {- ""- };+ let flag_note = get_flag_note(no_delete_branch, force_delete, integration_reason, None);super::success(cformat!("<green>Removed branch <bold>{branch_name}</>{flag_note}</>"))?;diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 9354bb0dd..e47224364 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -47,7 +47,7 @@ pub const WEEK: i64 = 7 * DAY;/// The command has the following guarantees:/// - All host `GIT_*` and `WORKTRUNK_*` variables are cleared/// - Color output is forced (`CLICOLOR_FORCE=1`) so ANSI styling appears in snapshots-/// - Terminal width defaults to 150 columns when `COLUMNS` is not already set+/// - Terminal width set to 150 columns (`COLUMNS=150`)pub fn wt_command() -> Command {let mut cmd = Command::new(get_cargo_bin("wt"));configure_cli_command(&mut cmd);@@ -101,9 +101,7 @@ pub fn configure_cli_command(cmd: &mut Command) {// Jan 2, 2025 - 1 day after default commit date (2025-01-01)// for deterministic "1d" in Age columncmd.env("SOURCE_DATE_EPOCH", "1735776000");- if std::env::var("COLUMNS").is_err() {- cmd.env("COLUMNS", "150");- }+ cmd.env("COLUMNS", "150");}/// Set `HOME` and `XDG_CONFIG_HOME` for commands that rely on isolated temp homes.diff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_matching_tree_content.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_matching_tree_content.snapindex 67f164a4b..56c6ab823 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_matching_tree_content.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_matching_tree_content.snap@@ -23,5 +23,5 @@ exit_code: 0----- stdout ---------- stderr ------⚪ [90mNo worktree found for branch feature-squashed[39m+🟡 [33m[33mNo worktree found for branch [1mfeature-squashed[39m[22m[39m✅ [32m[32mRemoved branch [1mfeature-squashed[22m[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_force_delete.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_force_delete.snapindex 251cba60d..9eccff10d 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_force_delete.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_force_delete.snap@@ -24,5 +24,5 @@ exit_code: 0----- stdout ---------- stderr ------⚪ [90mNo worktree found for branch feature-force[39m+🟡 [33m[33mNo worktree found for branch [1mfeature-force[39m[22m[39m✅ [32m[32mRemoved branch [1mfeature-force[22m (--force-delete)[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_merged.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_merged.snapindex c2260874a..479d03b90 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_merged.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_merged.snap@@ -23,5 +23,5 @@ exit_code: 0----- stdout ---------- stderr ------⚪ [90mNo worktree found for branch feature-merged[39m+🟡 [33m[33mNo worktree found for branch [1mfeature-merged[39m[22m[39m✅ [32m[32mRemoved branch [1mfeature-merged[22m[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snapindex 8e6f7f1a3..b0e676808 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_branch_only_unmerged.snap@@ -23,6 +23,5 @@ exit_code: 0----- stdout ---------- stderr ------⚪ [90mNo worktree found for branch feature-unmerged[39m-🟡 [33m[33mCould not delete branch [1mfeature-unmerged[39m[22m[39m-[107m [0m error: the branch 'feature-unmerged' is not fully merged+🟡 [33m[33mNo worktree found for branch [1mfeature-unmerged[39m[22m[39m+⚪ [90mBranch [1mfeature-unmerged[22m retained; not integrated into HEAD[39m