Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Include branch name in select preview messages
Maximilian Roos9fc49dbcfe91
diff --git a/src/commands/select.rs b/src/commands/select.rsindex f0339d19f..589b0bc51 100644--- a/src/commands/select.rs+++ b/src/commands/select.rs@@ -364,13 +364,17 @@ impl WorktreeSkimItem {let Some(wt_info) = self.item.worktree_data() else {// Branch without worktree - selecting will create one- return format!("{INFO_EMOJI} Branch only — press Enter to create worktree\n");+ let branch = self.item.branch_name();+ return format!(+ "{INFO_EMOJI} {branch} is branch only — press Enter to create worktree\n"+ );};+ let branch = self.item.branch_name();let path = wt_info.path.display().to_string();self.render_diff_preview(&["-C", &path, "diff", "HEAD"],- &format!("{INFO_EMOJI} No uncommitted changes"),+ &format!("{INFO_EMOJI} {branch} has no uncommitted changes"),width,)}@@ -380,14 +384,15 @@ impl WorktreeSkimItem {fn render_branch_diff_preview(&self, width: usize) -> String {use worktrunk::styling::INFO_EMOJI;+ let branch = self.item.branch_name();if self.item.counts().ahead == 0 {- return format!("{INFO_EMOJI} No commits ahead of main\n");+ return format!("{INFO_EMOJI} {branch} has no commits ahead of main\n");}let merge_base = format!("main...{}", self.item.head());self.render_diff_preview(&["diff", &merge_base],- &format!("{INFO_EMOJI} No changes vs main"),+ &format!("{INFO_EMOJI} {branch} has no changes vs main"),width,)}@@ -411,14 +416,13 @@ impl WorktreeSkimItem {// Alternative: Check specific conditions (main branch exists, valid HEAD, etc.) before// running git commands. This would provide better diagnostics but adds latency to// every preview render. Trade-off: simplicity + speed vs. detailed error messages.+ let branch = self.item.branch_name();let Ok(merge_base_output) = repo.run_command(&["merge-base", "main", head]) else {- output.push_str(&format!("{INFO_EMOJI} No commits\n"));+ output.push_str(&format!("{INFO_EMOJI} {branch} has no commits\n"));return output;};let merge_base = merge_base_output.trim();-- let branch = self.item.branch_name();let is_main = branch == "main" || branch == "master";if is_main {diff --git a/tests/integration_tests/snapshots/integration__integration_tests__select__select_abort_escape.snap b/tests/integration_tests/snapshots/integration__integration_tests__select__select_abort_escape.snapindex 99cfbabe0..08f34de32 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__select__select_abort_escape.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__select__select_abort_escape.snap@@ -5,7 +5,7 @@ expression: normalized> [QUERY] │[PREVIEW_HEADER]Branch Status HEAD± main↕ Path Remote⇅ Co│ctrl-u/d: scroll> @ main ^ . ..│- │⚪ No uncommitted changes+ │⚪ main has no uncommitted changes│││diff --git a/tests/integration_tests/snapshots/integration__integration_tests__select__select_multiple_worktrees.snap b/tests/integration_tests/snapshots/integration__integration_tests__select__select_multiple_worktrees.snapindex b753efab4..618553c62 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__select__select_multiple_worktrees.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__select__select_multiple_worktrees.snap@@ -5,7 +5,7 @@ expression: normalized> [QUERY] │[PREVIEW_HEADER]Branch Status HEAD± main↕ Path │ctrl-u/d: scroll> @ main ^ ./repo ..│- + feature-one _ ./repo.fea..│⚪ No uncommitted changes+ + feature-one _ ./repo.fea..│⚪ main has no uncommitted changes+ feature-two _ ./repo.fea..│││diff --git a/tests/integration_tests/snapshots/integration__integration_tests__select__select_with_branches.snap b/tests/integration_tests/snapshots/integration__integration_tests__select__select_with_branches.snapindex 48752acba..719bd934e 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__select__select_with_branches.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__select__select_with_branches.snap@@ -5,7 +5,7 @@ expression: normalized> [QUERY] │[PREVIEW_HEADER]Branch Status HEAD± main↕ Path │ctrl-u/d: scroll> @ main ^ ./repo │- + active-worktree _ ./repo..│⚪ No uncommitted changes+ + active-worktree _ ./repo..│⚪ main has no uncommitted changesorphan-branch _ ⎇ │││