Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: improve push message formatting
Maximilian Roosae0c3bc79f72
diff --git a/src/commands/beta.rs b/src/commands/beta.rsindex 9bac29b37..d9230f9a6 100644--- a/src/commands/beta.rs+++ b/src/commands/beta.rs@@ -172,9 +172,6 @@ pub fn handle_beta_squash(// Handle different scenariosif commit_count == 0 && !has_staged {// No commits and no staged changes - nothing to squash- crate::output::hint(format!(- "{HINT}No commits to squash - already at merge base{HINT:#}"- ))?;return Ok(false);}@@ -278,14 +275,7 @@ pub fn handle_beta_squash(/// Handle `wt beta push` commandpub fn handle_beta_push(target: Option<&str>, allow_merge_commits: bool) -> Result<(), GitError> {- super::worktree::handle_push(- target,- allow_merge_commits,- "Pushed to",- false,- false,- false,- )+ super::worktree::handle_push(target, allow_merge_commits, "Pushed to", None, None, None)}/// Handle `wt beta rebase` commanddiff --git a/src/commands/merge.rs b/src/commands/merge.rsindex 6eb57f34e..0b45aa450 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -219,9 +219,9 @@ pub fn handle_merge(Some(&target_branch),false,"Merged to",- committed,- squashed,- rebased,+ Some(committed),+ Some(squashed),+ Some(rebased),)?;// Get primary worktree path before cleanup (while we can still run git commands)diff --git a/src/commands/worktree.rs b/src/commands/worktree.rsindex 85836dd74..f48610b89 100644--- a/src/commands/worktree.rs+++ b/src/commands/worktree.rs@@ -629,13 +629,18 @@ pub fn execute_post_start_commands_sequential(Ok(())}+/// Push changes to target branch+///+/// The `committed`, `squashed`, and `rebased` parameters are optional flags indicating+/// whether those operations occurred in the merge workflow. Pass `None` for standalone+/// push operations where these concepts don't apply.pub fn handle_push(target: Option<&str>,allow_merge_commits: bool,verb: &str,- committed: bool,- squashed: bool,- rebased: bool,+ committed: Option<bool>,+ squashed: Option<bool>,+ rebased: Option<bool>,) -> Result<(), GitError> {let repo = Repository::current();@@ -724,17 +729,19 @@ pub fn handle_push(// Build parenthetical showing which operations didn't happen and flags usedlet mut notes = Vec::new();- // Skipped operations- let mut skipped_ops = Vec::new();- if !committed && !squashed {- // Neither commit nor squash happened - combine them- skipped_ops.push("commit/squash");- }- if !rebased {- skipped_ops.push("rebase");- }- if !skipped_ops.is_empty() {- notes.push(format!("no {} needed", skipped_ops.join("/")));+ // Skipped operations - only include if we're in merge workflow context (Some values)+ if committed.is_some() || squashed.is_some() || rebased.is_some() {+ let mut skipped_ops = Vec::new();+ if !committed.unwrap_or(false) && !squashed.unwrap_or(false) {+ // Neither commit nor squash happened - combine them+ skipped_ops.push("commit/squash");+ }+ if !rebased.unwrap_or(false) {+ skipped_ops.push("rebase");+ }+ if !skipped_ops.is_empty() {+ notes.push(format!("no {} needed", skipped_ops.join("/")));+ }}// Flag acknowledgments@@ -804,8 +811,27 @@ pub fn handle_push(summary_parts.join(", ")))?;} else {+ // No commits to push - for merge workflow context, acknowledge operations that didn't happen+ let note = if committed.is_some() || squashed.is_some() || rebased.is_some() {+ let mut notes = Vec::new();+ if !committed.unwrap_or(false) && !squashed.unwrap_or(false) {+ notes.push("no new commits");+ }+ if !rebased.unwrap_or(false) {+ notes.push("no rebase needed");+ }+ if notes.is_empty() {+ String::new()+ } else {+ format!(" ({})", notes.join(", "))+ }+ } else {+ // Standalone push - no merge workflow context+ String::new()+ };+crate::output::success(format!(- "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN:#}"+ "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN:#}{note}"))?;}diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snapindex 2cb4877cf..c7dd3bb20 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap@@ -2,5 +2,5 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----β [32mMerged to [1m[32mmain[0m[0m+β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)β [32mWorktree preserved (--no-remove)[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snapindex 6b1594551..a025de8e1 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap@@ -15,13 +15,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKgm0sH/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8fxCaQ/test-config.toml---success: trueexit_code: 0----- stdout ------π‘ [2mNo commits to squash - already at merge base[0m-β [32mMerged to [1m[32mmain[0m[0m+β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)β [32mWorktree preserved (--no-remove)[0m----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snapindex ab7137a09..da4eb515f 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap@@ -16,13 +16,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpFeWEub/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpF7qHqU/test-config.toml---success: trueexit_code: 0----- stdout ------π‘ [2mNo commits to squash - already at merge base[0m-β [32mMerged to [1m[32mmain[0m[0m+β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)β [32mReturned to primary at [1m[32m[REPO][0m[0mπ [36mRemoving worktree & branch...[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snapindex 537c98b5d..a09f3c248 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap@@ -15,13 +15,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpP0JvO5/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKQDc8U/test-config.toml---success: trueexit_code: 0----- stdout ------π‘ [2mNo commits to squash - already at merge base[0m-β [32mMerged to [1m[32mfeature[0m[0m+β [32mMerged to [1m[32mfeature[0m[0m (no new commits, no rebase needed)β [32mWorktree preserved (--no-remove)[0m----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snapindex d50501e76..cac44fd80 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpn0ZfDz/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqY4lHd/test-config.toml---success: trueexit_code: 0@@ -31,7 +31,7 @@ exit_code: 0[40m [0m - Change 2[40m [0m - Revert to initialβͺ [2mNo changes after squashing 3 commits[0m-β [32mMerged to [1m[32mmain[0m[0m+β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)β [32mReturned to primary at [1m[32m[REPO][0m[0mπ [36mRemoving worktree & branch...[0mdiff --git a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snapindex 5e5b348df..c1cd4b69d 100644--- a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap+++ b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap@@ -17,12 +17,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpMEHg8I/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9lwhzS/test-config.toml---success: trueexit_code: 0----- stdout ------π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m (no commit/squash/rebase needed)+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m[40m [0m * [SHA][33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add test file[40m [0m test.txt | 1 [32m+[mdiff --git a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap b/tests/snapshots/integration__integration_tests__push__push_no_remote.snapindex a749b466e..364e3bb9f 100644--- a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap+++ b/tests/snapshots/integration__integration_tests__push__push_no_remote.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp2mIKTU/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp1vgEVL/test-config.toml---success: trueexit_code: 0diff --git a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snapindex c0565ca11..75ab9d601 100644--- a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap+++ b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap@@ -17,12 +17,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpaGsNOh/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpFzk5oq/test-config.toml---success: trueexit_code: 0----- stdout ------π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m (no commit/squash/rebase needed)+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m[40m [0m * [SHA][33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature file[40m [0m feature.txt | 1 [32m+[mdiff --git a/tests/snapshots/integration__integration_tests__push__push_to_default.snap b/tests/snapshots/integration__integration_tests__push__push_to_default.snapindex a26db1649..3742b88bc 100644--- a/tests/snapshots/integration__integration_tests__push__push_to_default.snap+++ b/tests/snapshots/integration__integration_tests__push__push_to_default.snap@@ -16,12 +16,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyt5cTo/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRuxKWq/test-config.toml---success: trueexit_code: 0----- stdout ------π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m (no commit/squash/rebase needed)+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m[40m [0m * [SHA][33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add feature file[40m [0m feature.txt | 1 [32m+[mdiff --git a/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap b/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snapindex 8bc59c4b7..12c49ea33 100644--- a/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap+++ b/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap@@ -18,12 +18,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqnDjqt/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpApNe4v/test-config.toml---success: trueexit_code: 0----- stdout ------π [36mPushing 3 commits to [1m[36mmain[0m[36m @ [2m[SHA][0m (no commit/squash/rebase needed, merge commits allowed)+π [36mPushing 3 commits to [1m[36mmain[0m[36m @ [2m[SHA][0m (merge commits allowed)[40m [0m * [SHA][33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Merge temp[40m [0m [31m|[m[32m/[m